static

How do you create a static class in C++?

How do you create a static class in C++? I should be able to do something like: cout << "bit 5 is " << BitParser::getBitAt(buffer, 5) << endl; Assuming I created the BitParser class. What would the BitParser class definition look like? ...

Generics in c# & accessing the static members of T

Hi there! My question concerns c# and how to access Static memebers ... Well I don't really know how to explain it (wich kind of is bad for a question isn't it?) I will just give you some sample code: Class test<T>{ int method1(Obj Parameter1){ //in here I want to do something which I would explain as T.TryParse(...

Why can't I declare static methods in an interface?

The topic says the most of it - what is the reason for the fact that static methods can't be declared in an interface? public interface ITest { public static String test(); } The code above gives me the following error (in Eclipse, at least): "Illegal modifier for the interface method ITest.test(); only public & abstract are permi...

ASP.Net: Using System.Web.UI.Control.ResolveUrl() in a shared/static function

What is the best way to use ResolveUrl() in a Shared/static function in Asp.Net? My current solution for VB.Net is: Dim x As New System.Web.UI.Control x.ResolveUrl("~/someUrl") Or C#: System.Web.UI.Control x = new System.Web.UI.Control(); x.ResolveUrl("~/someUrl"); But I realize that isn't the best way of calling it. ...

using too much static bad or good ?

i like to use static functions in c++ as a way to categorize them, like c# does. Console::WriteLine("hello") but is it good or bad ? if the functions are often used i guess it doesn't matter, but if not do they put pressure on memory ? The same goes for static const... ...

Long-term Static Page Caching

I maintain several client sites that have no dynamic data whatsoever, everything is static asp.net with c#. Are there any pitfalls to caching the entire page for extreme periods of time, like a week? Kibbee, We use a couple controls on the sites (ad rotator, some of the ajax extensions) on the sites. They could probably be completely w...

When should a method be static?

In addition, are there any performance advantages to static methods over instance methods? I came across the following recently: http://www.cafeaulait.org/course/week4/22.html : When should a method be static? Neither reads from nor writes to instance fields Independent of the state of the object Mathematical methods tha...

Static class variables in Python

Is it possible to have static class variables or methods in python? What syntax is required to do this? ...

Why would a static inner interface be used in Java?

I have just found a static inner interface in our code-base. class Foo { public static interface Bar { /* snip */ } /* snip */ } I have never seen this before. The original developer is out of reach. Therefore I have to ask SO: What are the semantics behind a static interface? What would change, if I remove the st...

Variable declarations in header files - static or not?

When refactoring away some #defines I came across declarations similar to the following in a C++ header file: static const unsigned int VAL = 42; const unsigned int ANOTHER_VAL = 37; The question is, what difference, if any, will the static make? Note that multiple inclusion of the headers isn't possible due to the classic #ifndef HE...

Php Check If a Static Class is Declared

How can i check to see if a static class has been declared? ex Given the class class bob { function yippie() { echo "skippie"; } } later in code how do i check: if(is_a_valid_static_object(bob)) { bob::yippie(); } so i don't get: Fatal error: Class 'bob' not found in file.php on line 3 ...

Refactoring global to local. Should they be static or not?

I'm refactoring "spaghetti code" C module to work in multitasking (RTOS) environment. Now, there are very long functions and many unnecessary global variables. When I try to replace global variables that exists only in one function with locals, I get into dilemma. Every global variable is behave like local "static" - e.g. keep its valu...

Tool to optimize C# using statements?

Is there any tool out there that can identify name spaces in the Using statement that are not needed and eliminate them from the source? ...

Alternatives to static methods in Java

I'm making a mini ORM for a Java program I'm writing... there is a class for each table in my db, all inheriting from ModelBase. ModelBase is abstract & provides a bunch of static methods for finding & binding objects from the db, for example: public static ArrayList findAll(Class cast_to_class) { //build the sql query & execute it ...

What is data area?

In C++ the storage class specifier static allocates memory from the data area. What does "data area" mean? ...

Alternative to libraries of static classes

I have a large collection of static 'Utility' classes that contain very generic static methods. For example, I have a CollectionUtility class that has useful methods like: public static void RemoveDuplicates(ICollection collection)... etc With C# 3.0 I've been converting these to extension methods. Now, I've heard some talk that in an...

Order of static constructors/initializers in C#

While working on a C# app I just noticed that in several places static initializers have dependencies on each other like this: static private List<int> a = new List<int>() { 0 }; static private List<int> b = new List<int>() { a[0] }; Without doing anything special that worked. Is that just luck? Does C# have rules to resolve this? Ed...

Initializing static objects - Code design question

In my webapplication (C#, .Net 3.5), made up of a core class library (containing the business logic, data layer and a couple of utility classes), a windows service project, a webservice project and the website project, I have a couple of static classes in the core library used by all other projects. These classes (for example the Log cla...

Best Static Website Generator

In the age of dynamic websites built with layouts and templates, nobody wants to write plain old repetitive static html anymore. But now that you can outsource dynamic features to services like Disqus, and you could get slashdotted/dugg/reddited at any moment, sometimes a static website is best for scalability. There are quite a few st...

Problem with static library in C++

Hi all, I'm trying to use a static library created by me in Visual C++ 2005 (unmanaged C++). I declare one function "int myF(int a);" into a .h file, I implement it in a .cpp file, I compile it - the .lib file is produced. I create a new project (a separate solution) in VC++ 2005 (also native C++), I add the paths for the include file ...