I'm practicing a prototype program for a text-based game with complex character features. I have simplified much of what I already wrote, but I'm new to programming and have run into a problem.
I want to have a sub-class WaterBottle
that has an int drink
of value 3. I want another sub-class Hydration
to have an int called hydLvl
. I want a function within the Hydration subclass that is able to add the drink
value to the hydLvl
variable when used in the main
function.
class Character {
};
class Hydration : public Character {
public:
int hydLvl = 5;
int hydPrint(void) {
std::cout << "Hyd Lvl: " << hydLvl << endl;
return 0;
}
};
class WaterBottle : public Character {
public:
int drink = 3;
};
...
So far, I've been unable to successfully utilize the drink variable from the WaterBottle
class to modify the hydLvl variable from the Hydration
class.