This question is possibly a duplicate, but I am not sure because my program is in a single file.
// my-program.cpp
class A
{
public:
virtual void foo();
};
class B : public A
{
public:
void foo() {}
};
int main()
{
B myB;
}
Then I type g++ my-program.cpp
into the terminal, and the compiler gives me this warning:
Undefined symbols for architecture x86_64: "typeinfo for A", referenced from: typeinfo for Bin cce8BmNY.o "vtable for A", referenced from: A::A() in cce8BmNY.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status