I'm getting the error undefined reference to 'vtable for Base'
. I don't know what this means as I am not using anything called "vtable". Also, I don't exactly understand how making pointers and new Derived
are affecting the program. Can anyone clear this up? Thanks.
#include <iostream>
using std::cout;
class Base { // undefined reference to 'vtable for Base'
public:
void f();
virtual void bar();
};
class Derived : public Base {
public:
void f();
void bar() {
cout << "I am bar";
}
};
int main() {
Derived d;
Base * b = &d;
b->bar();
}