Reputation: 107
#include <iostream>
using namespace std;
class A{
public:
int a;
virtual void fun();
};
int main(){A obj;}
getting error undefined reference to 'vtable for A'. I want to know why without implement virtual function giving this type of error.
Upvotes: 1
Views: 114
Reputation: 847
That is because you are declaring the function (whether it would be normal member function or virtual function) but you are not defining it anywhere..!!
You can try this way, so that it would compile and run fine.!
class A{ public:int a; virtual void fun(){}; };
int main(){ A obj; }
Upvotes: 2