What is the best way to initialize a private, static data member in c++? I tried this in my header file, but it gives me weird linker errors: Class foo { private:

I have a question about the initialization of static variables in c. I know if we declare a global static variable that by default the value is 0. The local static variable will be initialized the first time this function is called. That is, the construction is delayed until the function is accessed the first time. Of course, if you use this function to initialize … The member is read-only, so it can be static const and i can define it outside the class, but that seems like an ugly hack. Is it possible to have private static data members in a class if i don't want to …

Of course, if you use this function to initialize … The member is read-only, so it can be static const and i can define it outside the class, but that seems like an ugly hack. Is it possible to have private static data members in a class if i don't want to … Iso c++ forbids in-class initialization of non-const static members. You can only do that for integral const static members, and that's because static const integral variables won't be actually put in …