/*********************************************
 File:   05Protected.cpp for CS319-Week 11
 What:   An class derive from a base class 
         with "protected" elements.
**********************************************/

#include <iostream>

// The base class
class Point {
protected:  // this was private in 04InheritExample.cpp
  int x;
public:
  Point(int X=0) {x=X;};
  int GetX(void) {return(x);};
  void SetX(int X) {x=X;};
};

// The derivated class will inherit x, GetX, SetX
class TwoPoint : public Point {
private:
  int y;
public:      
  // Don't have to use SetX in the constructor
  TwoPoint(int X=0, int Y=0) {x=X; y=Y;};
  int GetY(void) {return(y);};
  void SetY(int Y) {y=Y;};
  void PrintXY(void);
};

void TwoPoint:: PrintXY(void)
{
  // Don't have to use GetX
  std::cout << "(" << x << "," << 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);
}
