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.
posted @ 2017-06-25 08:33  llguanli  阅读(100)  评论(0编辑  收藏  举报