#include #include using namespace std; class base { public: base() {f();} //always calls base::f virtual ~base() {f();} //would also call base::f if we ever got this far virtual void f() const = 0; void g() const {f();} //doesn't necessarily call base::f }; class derived: public base { public: derived(): base() {} void f() const {cout << "derived::f\n";} }; int main() { derived d; return EXIT_SUCCESS; }