[ create a new paste ] login | about

Link: http://codepad.org/BIF4k5xf    [ raw code | output | fork ]

aaronla - C++, pasted on Aug 20:
#include <iostream>
#include <string>
using namespace std;

void doit(class Base*);

class Base {
public:
  virtual void foo() = 0;
  ~Base() { doit(this); } 
};

void doit(Base *p) { p->foo(); }

class Derived : public Base {
  string s;
public:
  Derived(string s) : s(s) {}
  virtual void foo() {   cout << "hello " << s << "\n"; }
};

int main ()
{
  Derived d("Derived");
}


Output:
1
2
3
pure virtual method called
terminate called without an active exception.
Aborted.


Create a new paste based on this one


Comments: