You've already declare the method static in the class definition, remove static from the method inplementation. E.g.,
void MyClass::setStaticVariable
{
myStaticVariable = anotherVariable;
}
Secondly, instantiate the static variable correctly. E.g.,
float MyClass::myStaticVariable = 10.1;
Regards.
Main Topics
Browse All Topics





by: glebspyPosted on 2002-10-20 at 23:17:23ID: 7351053
No, they dont have to be defined in the class. But when you define them outside the class, you shouldn't label them static (even though they the computer still knows they are static). Remove the keyword "static" from the "Offending section" and your code should not have that problem any more.
There's no particular reason, it's just how the language turned out. It's the same with the word "virtual".