/***********************************************
 File:   04InheritExample.cpp for CS319-Week 11
 What:   A first look at Inheritance
***********************************************/

#include <iostream>

// The base class
class Point {
private:
  int x;
public:
  Point(int X=0) {x=X;};
  int GetX(void) {return(x);};
  void SetX(int X) {x=X;};
};

// The derived class will inherit x, GetX, SetX
class TwoPoint : public Point {
private:
  int y;
public:
  TwoPoint(int X=0, int Y=0) {SetX(X); y=Y;};
  int GetY(void) {return(y);};
  void SetY(int Y) {y=Y;};
  void PrintXY(void);
};

void TwoPoint :: PrintXY(void){
  std::cout << "(" << GetX() << "," << y << ")" << std::endl;
}

int main(void)
{
  Point b;
  TwoPoint d;

  b.SetX(12);
  std::cout << "b.x=" << b.GetX() << std::endl;

  d.SetX(1); d.SetY(2);
  std::cout << "d=";
  d.PrintXY();

  return(0);
}
