1. 程式人生 > >Class example in C/C++

Class example in C/C++

article span ack track bsp alt play get heal

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++