Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   enum defined in struct (http://www.go4expert.com/forums/enum-defined-struct-t11548/)

naveenrai88 22Jun2008 09:50

enum defined in struct
 
Hi,
I have defined enum in struct as
/*************************************/
struct info
{
eunm { left, right} rotate;
int val;
};

int main()
{
struct info i;
i.rotate = right;
...
return 1;
}
/************************************/
while compiling this program, it is giving me an error

H:\naveen\try\main.cpp(76) : error C2065: 'RIGHT' : undeclared identifier
H:\naveen\try\main.cpp(76) : error C2440: '=' : cannot convert from 'int' to 'enum tree_rotation_info::rotation'
Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
H:\naveen\try\main.cpp(81) : error C2065: 'LEFT' : undeclared identifier
H:\naveen\try\main.cpp(81) : error C2440: '=' : cannot convert from 'int' to 'enum tree_rotation_info::rotation'
Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)

could u plz explain me about this error

thanks in advance

xpi0t0s 17Jul2008 15:44

Re: enum defined in struct
 
Try i.rotate = info::right;

naveenrai88 20Jul2008 09:00

Re: enum defined in struct
 
info undeclared error also added in it :((

xpi0t0s 20Jul2008 14:49

Re: enum defined in struct
 
What compiler and language are you using (language doesn't necessarily follow)? The following compiled perfectly in Visual Studio 2005:
Code:

void struct_test()
{
        struct info
        {
        enum { left, right} rotate;
        int val;
        };

        struct info i;
        i.rotate=info::right;
}



All times are GMT +5.5. The time now is 03:47.