class Player {
private:
int health; //these are the attributes
int strength;
int agility;
public:
void move();
void attackEnemy(); //these are the method prototypes
void getTreasure();
};
Every Player object which gets created has three integers called health, strength and agility for its attributes.
The methods we can perform on a Player object are move, attackEnemy and getTreasure.
时间: 2024-10-09 18:32:20