Undefined reference to vtable

前端 未结 16 2125
死守一世寂寞
死守一世寂寞 2020-11-21 20:30

When building my C++ program, I\'m getting the error message

undefined reference to \'vtable...

What is the cause of this probl

16条回答
  •  醉话见心
    2020-11-21 21:24

    I just ran into another cause for this error that you can check for.

    The base class defined a pure virtual function as:

    virtual int foo(int x = 0);
    

    And the subclass had

    int foo(int x) override;
    

    The problem was the typo that the "=0" was supposed to be outside of the parenthesis:

    virtual int foo(int x) = 0;
    

    So, in case you're scrolling this far down, you probably didn't find the answer - this is something else to check for.

提交回复
热议问题