#include<iostream>

using namespace std;

class I {
   int i;
public:
   I() : i(10) {}

// Take appropriate comments out, to examine the behavior
// virtual void foo()
   void foo()
   {  cout << "I::foo" << endl;
      play(); } // Bear in mind that this is: this->play()

// virtual void play()
   void play()
   {  cout << "I::play" << endl;
      cout << i++ << endl; }
};

class W : public I {
   int i;
public:
   W() : i(20) {}

// Try to comment out the foo() definition that follows
// combining with I::play() virtual
///*
   void foo()
   {  cout << "W::foo" << endl;
      play(); }
//*/
// Try to comment the play() definition:
// the inherited will access the I::i
///*
   void play()
   {  cout << "W::play" << endl;
      cout << i++ << endl; }
//*/
};

int main()
{
   I instr; instr.foo();
   W flute; flute.foo();

   I* pflute = &instr; pflute->foo();
   pflute = &flute; pflute->foo();

   return 0;
}
