#include <iostream>
int main()
{
// enum is like declaring your own type ( like int, char, float etc... )
// which can only contain specific values :
enum COLOR { BLACK, WHITE, GREEN, RED, YELLOW, BLUE };
// declare a variable of type COLOR :
COLOR color1, color2;
// since the type of color1, 2 and 3 is COLOR,
// we can only assign the values inside the enum
// COLOR to it :
color1 = YELLOW;
/***********************************
color2 = PINK; // this will cause compilation error since PINK is not declared
// in the COLOR enum
***********************************/
color2 = BLUE;
// and you can only use the values in the enum to compare it**
if( color1 == YELLOW && color2 == BLUE )
std::cout << "color1 and color2 makes green !!!" << std::endl;
else std::cout << "color1 and color2 doesn't make green :/" << std::endl;
return 0;
}
color1 and color2 makes green !!!
**Actually, you can also use integer values, since the first value in enum is assigned an int value of 0 ... and so on