How can i recieve a specific value from an enum from a given index.
enum genre { Pop, Jazz, Classic}; //enum
struct album
{
string album_name;
genre kind;
int track_number;
string tracks[5];
string tracklocation;
};
void main()
{
album x1;
cout<<"Enter genre 0->pop, 1->Jazz, 2->Classic\n";
cin>>temp;
x1.kind=(genre)temp; // typecasting for int to enum
cout<<x1.kind<<endl;
}
When i run this code i just get the integer value i input , instead of the converted enum value
what i need is when user input 0,1 or 2 it needs to be converted using the enum to the relevant genre and saved in the stucture variable.