首页 > 代码库 > Class example in C/C++

Class example in C/C++

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.

Class example in C/C++