jeudi 20 avril 2017

Should c++ pure virtual class needs definition?

// in header.h
class A {
    virtual ~A() = 0;

class B : public A {
    ~B() override {}

The linker reports that it cannot resolve external symbol "public: virtual __thiscall A::~A(void)" referenced in function "public: virtual __thiscall B::~B(void)"

I find that I have to write the definition of A::~A()

I used to think that pure virtual class defines interface(function declaration), and they don't have to contain function definition. Should I write definitions for all virtual functions in pure virtual base class? Or Should I just need to write the destructor function?


0 commentaires:

Enregistrer un commentaire