Sunday, April 3, 2011

Static Class Member Variables in C++

Recently when I tried to write a class with static member functions and variables, I found a strange linking error. No matter how I tried, the linker did not seem to be able to link those static member variables properly. After some searching, it seems to be a common compiler "feature" of C++....

In order to define the variable, define it outside the class definition, but the declaration is still inside the class.