Putting everything as public in a single class really doesn't solve anything.
To solve you undeclared variable problem, you need to instantiate you class.
Then every reference needs to be qualified as follows:
BTW, you can't initialize values in a class declaration.
As you've coded this, you're going to need to make
vars
global, so as I said, your class doesn't solve anything.
What you want to do is group data elements together that logically belong together.
For example, you have a number of elements related to player.
So:
1 2 3 4 5 6 7 8
|
class Player
{
private:
string age;
string name;
string gender;
... etc
};
|
Note that I've declared these private so they can not be accessed by code outside of the player class. You could set age, name, gender in the constructor for Player or you could have a prompt_for_player functiion that prompts for these values.
You probably want another class for Monster. Note that you've repeated some of your variables with 'O' in front of them (OType, OAttack, etc). I presume these are attributes of Monster.
Since both Player and Monster share attributes, you might want to make a base class that contains these elements. That way both Player and Monster would inherit elements and functions common to the base class.