#include <iostream>
#include <stdexcept>

struct A {
    A() { f(); }
    virtual void f() = 0;
};

void A::f() {
    std::cout << "A::f()" << std::endl;
}

struct B : public A{
    virtual void f() {
        A::f(); // <----- call default implementation
        std::cout << "B::f()" << std::endl;
    }
};

extern "C" void __cxa_pure_virtual() {
    throw std::runtime_error("Oh shit. I just called a pure virtual function ;(");
}

int main() {
    try {
        A *a = new B();
        a->f();
    } catch (std::exception &e) {
        std::cout << "Exception caught: " << e.what() << std::endl;
    }
    return 0;
}