Enum

Can enum type names be more than one word?
word? like
1
2
3
enum bolong_yu_is_a_programmer{
//blah blah
}
or
1
2
3
enum bolong yu is a programmer{
//blah blah blah
}
?
enum { orange, red };
Is this right?

enum Hair Colors {Black, Brown, Blonde, Red, Gray}
Just do
1
2
3
enum { black, brown, blonde, ext....}
std::cout << black << std::endl;
std::cout << brown << std::endl;


http://www.cplusplus.com/doc/tutorial/other_data_types/
Last edited on
Yes, it is correct. But be careful with the name Hair Colors, remember a valid C++ variable name do not contain SPACES, Hair Colors is not HairColors!
so you can have
enum HairColors{Black, Brown, Blonde, Red, Gray};
accessing it like
1
2
HairColors::Black //or
HairColors::Red
If you are using the same colors/values for more than just haircolors I wouldn't give the enum a name and just call the values by the color eg:
int a = black, b = brown;
Name of enum is an identifier. Identifiers in C/C++ may not have embedded spaces.
Topic archived. No new replies allowed.