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

后端 未结 2 1716
醉话见心
醉话见心 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:15

    To help anyone else that comes this way looking for help with "NOTE: a missing vtable usually means the first non-inline virtual member function has no definition."

    In my case the error was caused by a missing = 0; at the end of the virtual definition. Make sure all the virtual definitions have = 0; at the end.

    virtual HRESULT function(int testInput) = 0;
    

    Hopefully this saves someone some time.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题