enum defined in struct

naveenrai88's Avatar, Join Date: Jun 2008
Newbie Member
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
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Try i.rotate = info::right;
0
naveenrai88's Avatar, Join Date: Jun 2008
Newbie Member
info undeclared error also added in it (
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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;
}