Click on multiple.cpp to get source.

#include <iostream>
#include <strings.h>
#include <cstring>

using namespace std;

class W {
public:         char* f() {char *s = new char[7];  strcpy(s, "W::f()"); return s;}
public:    virtual char* g() {char *s = new char[7];  strcpy(s, "W::g()"); return s;}
};

class A : public virtual W {
public: char* f() {char *s  = new char[7];  strcpy(s, "A::f()"); return s;}
};

class B : public virtual W {
protected: char* g() {char *s  = new char[7];  strcpy(s, "B::g()"); return s;}
};

class C: public A, public B, public virtual W {
protected: char* f(){char *s  = new char[7];  strcpy(s, "C::f()"); return s;}
public:  char* h(){/* definition of C::h() */
                  char *s  = new char[7];
                  if (0) this->C::h();
                  cout << "In C::h(): " << this->A::f() << endl;
                  cout << "In C::h(): " << this->W::g() << endl;
                  cout << "In C::h(): " << ((B*)this)->f() << endl;
                  cout << "In C::h(): " << ((A*)this)->g() << endl;
                  strcpy(s, "C::h()"); return s;
                 }
};

int main(void){
W* wp; A a; B b; C c;
/* body of main program */
cout << c.h() << endl;
cout << c.A::f() << endl;
cout << c.W::g() << endl;
wp = (W*)&a; cout << wp->g() << endl;
wp = (W*)&b; cout << wp->g() << endl;
wp = (W*)&c; cout << wp->f() << endl;
wp = (W*)&c; cout << wp->g() << endl;
}