How would I do so without making base method virtual?
class Base { public: bool foo() const; } class Derived : public Base{ public: bool foo() const; } There is no any sense to call isEmpty of a derived class from isEmpty of the base class because the base class knows nothing about its derived classes. Take into account that the base class is single while there can be numerous derived classes. So of what derived class are you going to call function isEmpty?
There is sense to call isEmpty of the base class in a derived class. it can be done the following way
bool Derived::isEmpty() const { return Base::isEmpty(); } If you really need this, you can store a null pointer to a function with the foo's signature in your base class instances, and use the base implementation until this pointer is null. Then you can change this pointer in your derived class and associate is with your derived implementation. Then your base class can call that function via the pointer.
Below is some schematic code for this:
class Base { public: bool foo() const { if (NULL == internalFoo) { // base implementation; } else { return internalFoo(); } } private: bool (*internalFoo)() = NULL; } class Derived : public Base{ public: bool foo() const; } Derived::foo would have to be static to be able to get a normal pointer to it (perhaps taking the first parameter of Base* type and casting it internally to simulate this). With this change, this would be a good answer, IMO.
bool Base::isEmpty() const { Derived d; return d.isEmpty(); }.