Reputation: 689
I am confused about how enums work with classes..
Here is my test code... yes I know it doesn't work... http://ideone.com/oy3VH
Basically I have the test functions working... Testing2 and 3 are the same function, I only made them to for example purposes.
My confusion lies with "testing3". What I wish to do is access the switch statement by calling the object with a human readable value. like PlayAgain, or Instructions.
Now as you can see in line 79, this works.. but ONLY if declare the enume in main (or the w/e scope I call the object....
What I would like to do is WITHOUT a 2nd declaration use the enume name.. as in line 82?
Is that possible .. and if so how?
Thanks
Upvotes: 2
Views: 197
Reputation: 560
You need to scope your enums when using them outside of the class itself.
eg:
Func( cEnumtest::PlayAgain );
some other tips:
your enums are essentially integer constants. I suggest you have a naming convention that differentiates them from other code strictly for code-readability and clairty's sake.
eg: ('k' stands for constant ; 'c' would normally be used to indicate a class data type so that's why 'k' :)
enum eGameActions
{
kActionPlay,
kActionQuit,
kActionSaveGame
};
Upvotes: 2