C++, missing vtable compilation error -
i created interface (only .hpp file):
struct ia { public: virtual void foo(); }; and class implementing interface (.hpp)
class : public ia { virtual void foo(); } and .cpp
void a::foo(){...} this compiles without problem, when use
ia a; in file compilation error: "vtable ia, referenced from: ia::ia() in libsomeotherfile.a(someotherfile.o) note: missing vtable means first non-inline virtual member function has no definition" know why , how fix ?
if goal make interface, should not creating instance of interface type directly. use pointer instead:
ia *a = new a(); additionally, if isn't meant instantiated should make foo pure-virtual in ia:
/* in ia */ virtual void foo() = 0;
Comments
Post a Comment