<se*****@gmail.comwrote in message
news:11**********************@c51g2000cwc.googlegr oups.com...
can we define enum within a structure??
for example,
typedef enum {red,blue}color;
struct s1{
color c;
}obj;
obj.c = blue;
Is it possible?? if yes, can anybody tell me how it possible??
It is possible because you can consider the type of an enum as int so it's
no more special than having an int member.
Beware though that if you do something like
struct X
{
enum Colour { red, green } col;
};
The enum Colour is actually *not* an embedded type as it would be in C++ so
the following should still compile
Colour c = green;
This would be an error in C++