Possible Duplicate:
Calling virtual method in base class constructor
Calling virtual functions inside constructors
How can I call a protected virtual method from a constructor in C++?
class Foo
{
Foo(){
printStuff(); // have also tried this->printStuff()
}
protected:
virtual void printStuff() {}
}
class ExtendedFoo : public Foo {
protected:
virtual void printStuff() { cout << "Stuff" << endl;}
}
...
ExtendedFoo exFoo; // should print "Stuff"