Hello,
I have delcared a class with enum as follows:
Code:
class TokenPrint {
protected:
public:
static enum TokenType {TOKEN_ANCHOR=0, TOKEN_ARGUMENT_STRING=1,
TOKEN_ARGUMENT_INT=2, TOKEN_VALUE_STRING=3, TOKEN_VALUE_INT=4} TokenType;
enum TokenType tokenType ;
tokenType is a enum variable that can take a value of 5 values list above.
In my copy consturctor, the assignment didn't generate any compile error as long as I access it as a local variable.
Code:
TokenPrint::TokenPrint(const TokenPrint &_tokenPrint) {
tokenType=_tokenPrint.tokenType;
tokenType=TOKEN_ANCHOR; //compiles ok
tokenType=TokenPrint.TOKEN_ANCHOR; //compile error
}
This creates a problem because I am trying to initialize the tokenType outside of the class functions:
Code:
tokenPrint.tokenType=TokenPrint.TokenType.TOKEN_ACHOR; //compile error
I tried to move the static enum TokenType delcaration outside of the class, but it gives me duplicate definition. I can probably find a work-around using #ifnef
but it's just useful to keep all the declaration inside the class.