TITLE: The multiple inheritance "dominance" rule

[ This example adapted from "C++ Gotchas", tutorial notes
  copyright by Tom Cargill, p. 73. ]


#include <iostream.h>


class Top {
  public:
            void f() { cout << "Top::f" << endl; }
    virtual void v() { cout << "Top::v" << endl; }
};


class Left : public virtual Top {
  public:
};


class Right : public virtual Top {
  public:
    void f() { cout << "Right::f" << endl; }
    void v() { cout << "Right::v" << endl; }
};


class Bottom : public Left, public Right {
};


int main ()
{
    Bottom b;
    b.f();                   // non-virtual call

    Left* p = new Bottom;
    p->v();                  // virtual call

    return 0;
}


This program outputs the lines below. For more information
see ARM p. 204.

Right::f
Right::v

