array in enum?
-
dear All, Just wondered if one knows how to use an array in enum. this would be more convenient then 100 diffreent variables. many thanks, Dominik
I'm not quite sure I understand your question. The enum statement takes the form:
enum Colors
{
Red,
Blue,
Green,
Yellow,
Brown
};At this point, there are no variables, only one enumerable type.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
-
dear All, Just wondered if one knows how to use an array in enum. this would be more convenient then 100 diffreent variables. many thanks, Dominik
-
As unsure as DavidCrow in what you mean. Assuming you mean an array of enumerated values, then the answer is simple: typedef enum { Blue, Red, Yellow } Color; Color colors[100]; Otherwise... please clarify.
I think he needs a struct or class. He's thinking along these lines (I think)
typedef enum { Blue, Red, Yellow, int nTypes[9] };
I don't think this is possible in an enum My articles www.stillwaterexpress.com BlackDice
-
I think he needs a struct or class. He's thinking along these lines (I think)
typedef enum { Blue, Red, Yellow, int nTypes[9] };
I don't think this is possible in an enum My articles www.stillwaterexpress.com BlackDice
-
Thanks a lot for your help! Yep, i was after something along these lines: typedef enum { Blue, Red, Yellow, green[9] }; ok, now i know that i need and int in front of green[9]. that helps a lot! will try this tonight!!! many thanks, Dominik
ahhh, no, i just see that this is not possile. however, using struct or a class will be a bit unconvenient since it doesn't number the variables automatically. i just like.... typedef enum { Blue, Red, Yellow, Green[9] }; anything else messes up the code i believe, Dominik no one's got an idea???? thanks, Dominik