-
accessing enum members
I'm trying to access the enum as described below:
Code:
enum SomeEnum
{
memberA = ...;
memberB = ...;
// more members
};
I'm trying to use one of the members of the enum as shown in an example function call here:
Basically, how would I access any member of the enum properly?
-
You don't access the members of an enum.
You see, an enum is a type of variable that can be assigned to one of many different values. For example:
Code:
enum fruit {
apple,
pear
};
fruit favourite = apple;
if(favourite == pear) {
/* ... */
}
etc.
Defining an enum makes the values of the enum visible, like constants or #defines, and those values can be assigned to variable of the enum's type.
[edit] http://www.cprogramming.com/tutorial/enum.html [/edit]
[edit] If you're looking for a construct where you can access the members, look up structs, classes, or perhaps unions (but probably not). [/edit]