// INHERITANCE - create hierarchial relationships between objects
// allows child (derived) class to use data/functions from parent(base) class

// private - visible only in the class and friends
// public - visible in subclasses and clients
// protected - visible in the class and subclasses, but not clients

#include <iostream>

using namespace std;

class Base
{
  public:
    Base() { cout << "Base constructor" << endl; }
    ~Base() { cout << "Base deconstructor" << endl; }

    void public_base() { cout << "Public base" << endl; }

  private:
    void private_base() { cout << "Private base" << endl; }
};

class Derived: public Base
{
  public:
    Derived() { cout << "Derived constructor" << endl; }
    ~Derived() { cout << "Derived deconstructor" << endl; }

    void public_derived() { cout << "Public derived" << endl; }

  private:
    void private_derived() { cout << "Private derived" << endl; }
};

int main()
{
  Base b;
  Derived d;

  b.public_base();

  // Errors
  // b.private_base();
  // d.private_base();
  // d.private_derived();

  d.public_base();
  d.public_derived();

  return 0;
}

// OUTPUT

// Base constructor
// Base constructor
// Derived constructor
// Public base
// Public base
// Public derived
// Derived deconstructor
// Base deconstructor
// Base deconstructor

// EOF