In C i can test the value of an enum using if/else statement. For example:
enum Sport {Soccer, Basket};
Sport theSport = Basket;
if(theSport == Soccer)
{
// Do something knowing that it is Soccer
}
else if(theSport == Basket)
{
// Do something knowing that it is Basket
}
Is there another way to do this work with C++?
Yes, instead of using if-else statement, you can use virtual functions as part of interfaces.
I make you an example:
And after use your object in this way:
This is thanks to the fact that C++ adds object oriented features.