previous | index | next

The MoveInfo Class

The MoveInfo Class Header

class MoveInfo {
public:
  MoveInfo(int coins, int pile);
  int getCoins();
  int getPile();
private:
  int coins;
  int pile;
};

Defining the MoveInfo Class Members

MoveInfo::MoveInfo(int coins, int pile) {
  this->coins = coins;
  this->pile = pile;
};

int MoveInfo::getCoins() {
  return coins;
}

int MoveInfo::getPile() {
  return pile;
}

The this keyword is used to disambiguate the parameter names from instance variable names.

this is a reference to the current object.


previous | index | next