enum Ship
{
SHIP_BATTLESHIP,
SHIP_AIRCRAFT_CARRIER,
SHIP_CARGO_SHIP,
SHIP_DESTROYER,
SHIP_BARGE,
SHIP_TUGBOAT,
};
How do I add SHIP_TITANIC to the list? I have tried static cast and it doesnt work/am not doing it right:
What does this statement do? 5 of what? What equals 5? |
Color color = COLOR_CYAN;
Last edited on
Color color = COLOR_CYAN;
but we already knew that from our list right?
Um... no. Your so-called "list" doesn't say anything about a variable called color.
Your enum statement is defining a type called Color.
This:
Color color = static_cast<Color>(5); // ugly
declares a variable called color of that type, and initialises its value to COLOR_CYAN.
This:
Color color = COLOR_CYAN;
does exactly the same thing.
EDIT: A little part of me dies inside every time I have to use the American spelling of "colour" :P
Last edited on
SHIP_BATTLESHIP = ship;
What are you trying to do here? This statment is equivalent to -5 = ship;
SHIP_BATTLESHIP = ship;
changed to this:
SHIPS SHIP_BATTLESHIP = ship
I am trying to allow the user to input and change the enum value.
Last edited on
You can't do that. That's like asking the user to enter a new value for the number "-5".
In your enum definition, you're telling the compiler that the symbol SHIP_BATTLESHIP means "-5". You can't change that at runtime.
Why would you even want the user to be able to change that value? What purpose would it serve?
Last edited on