static

Why use an object instance rather than class::staticFunction?

Why should I use an object instance to access member functions rather than class::staticFunction? ( or why not? ) ...

C# - Get values of static properties from static class

I'm trying to loop through some static properties in a simple static class in order to populate a combo box with their values, but am having difficulties. Here is the simple class: public static MyStaticClass() { public static string property1 = "NumberOne"; public static string property2 = "NumberTwo"; public static string...

Statically linking a DLL in Windows

Consider this situation: I'm creating a DLL (let's call this dllA), which, in turn, calls functions in other DLLs (let's call these dllX, dllY and dllZ). If someone else wanted to use dllA, they'd need a copy of dllX, Y and Z as well. Is there a way to build dllA such that the needed functions in dllX, Y and Z get linked into dllA? I ...

How to initialize a static member

Hi, I want to initialize two static data members. See the two files //Logger.h class Logger{ public: static LoggerConcrete error; static LoggerConcrete write; }; and //Logger.cpp Logger::error = LoggerConcrete(LOG_DEBUG); Logger::write = LoggerConcrete(LOG_DEBUG); The initilization of the two static ...

JSF - calling FacesContext.getCurrentInstance() in a static context

Am I right in thinking that this may not be the best idea: private static Application app = FacesContext.getCurrentInstance() .getApplication(); ... or any other call to FacesContext.getCurrentInstance() when you can't be sure that the current thread of execution is due to a servlet request? The way I understand it, FacesCont...

With GCC, how do I export only certain functions in a static library?

I've created a static library in GCC, but I'd like to hide most of the symbols. For example, test1.c: extern void test2(void); void test1(void) { printf("test1: "); test2(); } test2.c: extern void test1(void); void test2(void) { printf("test2\n"); } library_api.c: extern void test1(void); extern void test2(void); void libra...

How do parameters and their usage in methods effect the static/instance design decision?

Just a simple question: I have read that a class should be made static when it does not modify its instance. So if I have a class which is called Account and it has properties such as Id, Duration, etc and these do not get modified by the class, then this can be made static otherwise it should remain static. How does this (whether the ...

Java - Why all fields in an interface are implicitly static and final?

I am just trying to understand why all fields defined in an Interface are implicitly static and final. The idea of keeping fields static makes sense to me as you can't have objects of an interface but why they are final (implicitly)? Any one knows why Java designers went with making the fields in an interface static and final? ...

in-class initialization of non-integral static data

So I just learned via a compiler error that in-class initialization of arrays is invalid (why?). Now I would like to have some arrays initialized in a template class, and unfortunatly the contents depend on the template parameter. A condensed testcase looks like this: template<typename T> struct A { T x; static const int len = s...

Declaring a non static const array as class member

How can we declare a non static const array as an attribute to class. Following code produces compilation error (“'Test::x' : member could not be initialized”)? class Test { public: const int x[10]; public: Test() { } }; ...

Java : static fields behaviour in different executions

I have this class : package scripts; public class TestStatic { public static void main(String[] args) { new IncrA().incrStatic(); } } class Static { public static int CPT = 0; } class IncrA{ public void incrStatic(){ for (int i:Range.ints(0,100)){ System.out.println("Now with "+this.toString()+" : Static.CPT="+Static.C...

Objective C - Where do you dealloc global static variables?

Or, what is the opposite of +(void)initialize? Here's my situation: I have a class Unit, whose -(id)initWithName: function takes data from a global NSDictionary, which is created lazily, defined in the Unit.m file as: static NSMutableDictionary *unitLibrary = nil; Where do I call [unitLibrary release]? ...

In what situations is static method a good practice?

I have read the following discussions: http://stackoverflow.com/questions/538870/java-static-methods-best-practices , and http://stackoverflow.com/questions/658407/static-methods It seems that people in general would accept static methods, but are a little bit skeptical about it, for the following 2 reasons: They are hard to test. Th...

Static allocation vs. Dynamic allocation vs. Automatic allocation

What are the differences among static, dynamic, and automatic allocation? ...

Static variables in JavaScript

How can I create static variables in Javascript? ...

C++ static global non-POD: theory and practice

I was reading the Qt coding conventions docs and came upon the following paragraph: Anything that has a constructor or needs to run code to be initialized cannot be used as global object in library code, since it is undefined when that constructor/code will be run (on first usage, on library load, before main() or not at all). Even i...

Compiling a 'static' binary from fortran on mac

Hi, I would like to compile fortran code on mac such that it does not depend on any shared library. Ultimately, I want to be able to send the binary to other people and for it to just work (provided the processor has the right architecture). I noticed that g95 and ifort have a -static flag, which does not work on mac. If I consider the...

How to make a library depending statically to link dynamic on HP?

I built few open source binary/libraries and found that the binary/library is dependent on other libraries statically.I want it to link dynamically. This would allow my binaries be moved to any location and will be path independent. I mean if i export the Library path the binary should be able to locate the library and run successfully. ...

How do I require Gosu with IronRuby?

I tried to require Gosu's .so file, but it said something about "expecting assembly", I assumed that IronRuby will support library files which aren't written in dot net, may anybody help me please? ...

Are C# extension methods only available for instance methods?

I have recently started to make useful use of C# extension methods. The SO examples and the documentation suggest that they are only used for instance methods (i.e. with the this keyword). It is possible to use them (or another approach) with static/class methods? (My particular requirement is converting Java code to C# where "most of ...