A missing vtable usually means the first non-inline virtual member function has no definition

后端 未结 2 1742
醉话见心
醉话见心 2021-01-01 20:37

I am pretty sure this question is duplicate, but my code is different here, the following is my code. It fails with a \"Undefined symbols\" error, not sure whats missing.

2条回答
  •  轮回少年
    2021-01-01 21:33

    Parent::~Parent() is not defined.

    You can put the definition directly into the class definition:

    class Parent {
       public :
         virtual int func () = 0;
         virtual ~Parent() {};
     };
    

    Or define it separately. Or, since C++11, write virtual ~Parent() = default;.

    In any case, a destructor needs a definition.

提交回复
热议问题