The following is my code:
enum Color {red, blue};
enum Number {3,4};
enum Shape {circle, square};
struct article
{
enum Color color;
enum Number number;
enum Shape shape;
} article_1;
//assume I have the below for all three enums
std::istream& operator>>( std::istream& is, Color& I )
{
int tmp ;
if ( is >> tmp )
i = static_cast<Color>( tmp ) ;
return is ;
}
int main ()
{
cout<<"Enter the Color : ";
cin>>article_1.color;
cout<<"Enter the Number : ";
cin>>article_1.number;
cout<<"Enter the Shape : ";
cin>>article_1.shape;
return 0;
}
The code compiles without any errors. However, when the terminal pops up asking me to enter the color, when I enter red, the terminal disappears and I get an error saying Program.exe has exited with code 0(0x0)
. What am I doing wrong?