Click on multiple.cpp to get source.
#include <iostream>
#include <strings.h>
#include <cstring>
#define MAXSTRLEN 50

using namespace std;

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

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

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

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

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