enum defined in struct

Discussion in 'C' started by naveenrai88, Jun 22, 2008.

  1. naveenrai88

    naveenrai88 New Member

    Joined:
    Jun 17, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Try i.rotate = info::right;
     
  3. naveenrai88

    naveenrai88 New Member

    Joined:
    Jun 17, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    info undeclared error also added in it :((
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    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;
    }
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice