I have the following code:
class Father
{
public:
virtual void sleep() = 0;
protected:
Father();
~Father();
}
// Both sleep() and Son(int, int, int) are implemented in son.cpp
class Son : Father
{
Son(int a, int b, int c);
void sleep() override;
}
In main:
Son son(1, 2, 3);
When I try to compile, I get this error:
In sketch\src\son.cpp.o undefined reference to `Father::Father()'
The same error also for the destructor.
What is happening here? I never mentioned or included Father in the son.cpp.
I tried to remove the declaration of the constructor and destructor from the father, then it worked.
UPDATE:
My goal here is to prevent instantiating the abstract
Father. So I don't want to remove the declaration of the constructor.