Tuesday, 5 January 2016

Accessing the enum declared inside the class

 

Enums which is declared inside the class should be accessed with help of class name followed by scope resolution operator.

Syntax:
ClassName::EnumValue

#include<iostream>

struct test

{
   enum op

   {

      mytrue,
      myfalse,

   };

};

int main()

{
   printf("\n  :: %d ", test::myfalse );
   return 0;

}