// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <cstdlib>

using namespace std;

class P1
{
   public:
      void foobar();
};

class C1 : public P1
{
   public:
      void foobar();
};

class P2
{
   public:
      virtual void foobar();
};

class C2 : public P2
{
   public:
      virtual void foobar();
};

void P1::foobar()
{
   cout << "P1" << endl;
   return;
}

void C1::foobar()
{
   cout << "C1" << endl;
   return;
}

void P2::foobar()
{
   cout << "P2" << endl;
   return;
}

void C2::foobar()
{
   cout << "C2" << endl;
   return;
}

int main(int argc,char *argv[])
{
   P1 *p1 = new P1();
   p1->foobar();
   P2 *p2 = new P2();
   p2->foobar();
   C1 *c1 = new C1();
   c1->foobar();
   C2 *c2 = new C2();
   c2->foobar();
   P1 *m1 = new C1();
   m1->foobar();
   P2 *m2 = new C2();
   m2->foobar();
   exit(EXIT_SUCCESS);
}
