純粋仮想関数: 下に丸投げ

#include <iostream>

using namespace std;

class Foo {
public:
  virtual void vfunc() = 0;
};

class Bar : public Foo {
public:
  virtual void vfunc() = 0;
};

class Zoo : public Bar {
public:
  void vfunc() {
    cout << "Zoo::vfunc()" << endl;
  }
};

int main() {
  Foo *foo;
  Bar *bar;
  Zoo zoo;

  foo = &zoo;
  foo->vfunc();

  bar = &zoo;
  bar->vfunc();
  return 0;
}


Zoo::vfunc()
Zoo::vfunc()