locked
Cannot cast to/from enum class

    Question

  • I have a simple enum class with a single member.  I cannot seem to cast to or from this enum.  Is there any way to do this cast?  I keep getting "An internal error has occurred in the compiler."
    Sunday, October 09, 2011 10:13 PM

All replies

  • Hello,

    Could you post the code where you are getting the internal error?  I tried a simple repro like but it ran fine

     

    enum class Test : unsigned int {
     Passed,
     Failed
    };

    enum class Test2 {
     Red,
     Blue
    };

    int _tmain(int argc, _TCHAR* argv[])
    {
     
     Test status;

     status = Test::Passed;

     int i;

     i = (int) status;
     
     cout << i << endl;
     
     Test2 color;

     color = Test2::Blue;

     i = (int) color;

     cout << i << endl;

     

    thanks!

    mike

    Tuesday, October 11, 2011 6:05 PM
    Moderator