c++ - Putting class static members definition into cpp file -- technical limitation? -
While coding in C ++, declaring some stable variable in my class, and seeing the compilation error in it
One of my "favorite" annoyance
I mean classic example:
Test.h
test of class {Personal: Stable Int M_StaticWara ; Int m_var; }
Test.cpp
Full test :: m_staticVar;
It is more misleading in my eyes which is the syntax of this definition, you can not use the word 'stable' here (as used in CPP, steadily different meaning You do not know) (Knowledge stable working without leaving Vars) Why there is something different from the test class defined on Earth and why m_var is not.
For your knowledge / opinion, why is he? I can think of only one reason and this is making life easier for Linker - that is why you can not use non-integral constants (some classes m_var = anything). But I do not like an idea of bending language features, because some part of the compilation series can eat hard times ...
Well, this is the way to work. You have declared the only stable member in .h file. Linker needs to be able to find an definition of that stable member in the object files, which link it together. You can not define a definition in .h file, which can generate several definitions.
Comments
Post a Comment