static const member variables
I received the following errors while trying to compile my program:
error C2864: 'GameStates::PlayGameState::firstTry' : only static const integral data members can be initialized within a class
The error occurs on the line "bool firstTry = true;"
Since I have plenty of variables above this call that work just fine, I'm going to take a guess that the error has to do with the bool type. I only say this because the firstTry declaration is the only bool variable declared.
Am I on the right track here?
I understand that... but why are their inclusions necessary?
furthermore, what am I suppose to do if I don't want the variable to be constant.
furthermore, what am I suppose to do if I don't want the variable to be constant.
Standard fiat. That's just the way the language is defined. It gets changed in C++0x, but you apparently aren't using a C++0x compiler.
class PlayGameState{public: PlayGameState() : firstTry(true){} /*...*/bool firstTry; };
Use an initialization list to initialize variables in classes.
Quote:Original post by zoner7
furthermore, what am I suppose to do if I don't want the variable to be constant.
Just don't initialize your variables within the class declaration. Have the constructor set it to true.
EDIT: like caldiar said.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement