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-02 09:11  yfceshi  阅读(155)  评论(0编辑  收藏  举报