ex7-7.cpp - Example 7-7 Multiple inheritance

// File: ex7-7.cpp - Easy multiple inheritance example

#include <iostream>
using namespace std;

class one
{
  protected:
    int a,b;
  public:
    one(int z,int y) { a = z; b = y; }
    void show(void) const { cout << a << ' ' << b << endl; }
};

class two
{
  protected:
    int c,d;
  public:
    two(int z,int y) { c = z; d = y; }
    void show(void) const { cout << c << ' ' << d << endl; }
};

class three : public one, public two
{
  private:
    int e;
  public:
    three(int,int,int,int,int);
    void show(void) const
    { cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << endl; }
};

three::three(int a1, int a2, int a3, int a4, int a5)
: one(a1,a2),two(a3,a4)
{
  e = a5;
}

int main(void)
{
  one abc(5,7);
  abc.show();	// prints 5 7
  two def(8,9);
  def.show();	// prints 8 9
  three ghi(2,4,6,8,10);
  ghi.show();	// prints 2 4 6 8 10

  return 0;
}



CIS27: Programming in C++    Instructor: Joe Bentley