T
Teddy
what is the special meaning of enum members in class ?
Teddy said:what is the special meaning of enum members in class ?
Larry said:An example:
--- en.cpp ---
// a global enum named MyColor
enum MyColor { Red, Green, Blue };
// a simple class with an enum and a variable of that
// enum type
class Test
{
public:
enum TestEnum
{
value1,
value2
};
TestEnum enumVar;
};
int main()
{
// a variable named 'clr' of type 'MyColor'
// with a value of 'Green'
MyColor clr = Green;
// a Test object named 'tst'
Test tst;
// a variable named 'value' of type 'Test::TestEnum'
// with a value of 'Test::value2'
Test::TestEnum value = Test::value2;
// assign the value 'Test::value1' to the
// 'enumVar' member of 'tst'
tst.enumVar = Test::value1;
return 0;
}
Regards,
Larry
Teddy said:what is the special meaning of enum members in class ?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.