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

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -