Multiple Inheritance

#include < stdio.h>
#include < iostream.h>

class A
{
public:
  virtual char f(void) { return 'A'; }
  virtual char h(void) { return 'A'; }
  //  virtual char j(void) { return 'A'; }
  char g(void) { return 'A'; }
  char tf(void) { return f(); }
  char tg(void) { return g(); }
};

class C : public virtual A
{
public:
  //char f(void) { return 'C'; }  "Can't have f() in classes B and C
  //  virtual char j(void) { return 'C'; } Not allowed
  char g(void) { return 'C'; }
  virtual char h(void) { return 'C'; }
};

class B : public virtual A
{
public:
  //  virtual char j(void) { return 'B'; }  Not allowed - virtual function is abstract: j()
  char f(void) { return 'B'; }
  char g(void) { return 'B'; }
  virtual char h(void) { return 'B'; }
};

class E : public C, public B
{
public:
  E() {}
  char h(void) { return 'E'; }
};

class D : public B, public C
{
public:
  D() {}
  char h(void) { return 'D'; }
};

int main()
{
   E *e = new E();
   D *d = new D();

   cout 
     << e->h()  // E
     << e->f()  // B
     // e->g()                  "Request for g() is ambiguous"
     << " "
     << ((A *)e)->f()  // B
     << ((A *)e)->h()  // E
     << ((A *)e)->g()  // A             A: f*,h*,g,tg,tf
     << ((A *)e)->tf() // B
     << ((A *)e)->tg() // A          B: f,g,h*      C: g,h*
     //     << ((A *)e)->j()
     << " "              //               D: h     E: h
     << ((B *)e)->f()  // B
     << ((B *)e)->h()  // E
     << ((B *)e)->g()  // B
     << ((B *)e)->tf() // B
     << ((B *)e)->tg() // A
     << " "
     << ((C *)e)->f()  // B
     << ((C *)e)->h()  // E
     << ((C *)e)->tf() // B
     << ((C *)e)->tg() // A
     << " "
     << d->h()         // D
     << d->f()         // B
     //	<< d->g()                 "Request for g() is ambiguous
     << " "
     << ((A *)d)->f()  // B
     << ((A *)d)->h()  // D
     << ((A *)d)->g()  // A
     << ((A *)d)->tf() // B
     << ((A *)d)->tg() // A
     << " "
     << ((B *)d)->f()  // B
     << ((B *)d)->h()  // D
     << ((B *)d)->g()  // B
     << ((B *)d)->tf() // B
     << ((B *)d)->tg() // A
     << " "
     << ((C *)d)->f()  // B
     << ((C *)d)->h()  // D
     << ((C *)d)->tf() // B
     << ((C *)d)->tg() // A
	<< "\n";
}