Archived

This topic is now archived and is closed to further replies.

TheOne1

enumerated constants

Recommended Posts

i was wondering 2 things. 1. enum BREED { GOLDEN, LABRADOR } Now, I know that GOLDEN = 1, and LABRADOR = 2 but do enumerated constants have a type? Like int, short unsigned, etc. 2. enum BREED { GOLDEN, LABRADOR } ..... //code ......//code, etc, etc, BREED breed; Is BREED breed kind of like an variable type? Kind of like int x, y; or is it like a class type like: DOG Brownie;? Kind of confusing sorry, ill clear it up if to hard to understand.

Share this post


Link to post
Share on other sites
Well, I know the constants that are declared with an enumeration are integers. The enum itself however, I don''t really know. Isn''t it just a new type, in your case BREED.

And also, the values will start with 0: GOLDEN = 0 and LABRADOR = 1.

Share this post


Link to post
Share on other sites
Well if I had to classify it I would say that enum is one way to create user-defined types. Those int, float, double etc. are all built-in types, meaning you don''t have to define them to use them. Enum is really more of an aesthetic feature so that you''re code is easier to read using words instead of numbers but the actual internal representation of it is still an int type.





You fight like a dairy farmer.

Share this post


Link to post
Share on other sites