#include <iostream>
usingnamespace std;
enum DIRECTION_t
{
int NO_MOVEMENT;
int LEFT;
int RIGHT;
int UP;
int DOWN;
};
int main()
{
int Choice = NO_MOVEMENT;
cout << "What direction do you want to move? Enter 1, 2, 3, or 4" << endl;
cin >> Choice
switch(Choice)
{
case LEFT:
cout << "You moved left" << endl;
break;
case RIGHT:
cout << "You moved right" << endl;
break;
case UP:
cout << "You moved up" << endl;
break;
case DOWN:
cout << "You moved down" << endl;
break;
default NO_MOVEMENT:
cout << "You moved nowhere" << endl;
break;
}
return 0;
}
Not only that, Grey Wolf, but he doesn't use his enum anywhere in his program. Choice is of type INT, so it can't store "DOWN". It can store the ASCII VALUE of DOWN, but not text. If you want to store text in a variable, the variable needs to be of type string, or a char array. Also, to declare a variable of your enum type, you need to do this...
Because the way he's coding, he doesn't seem to know about other data types. If he did, he would know that an integer cannot hold anything but integers. It can store the ASCII value of text, as I said, but for what he's looking to do, it will not work.
I didn't know you could use any other data type for enums my book I'm learning from has like a half of page about enums. I hadnt even gotten to the easy errors because the enum errors where higher up so I addressed those first.