C ++ error: cannot declare field of abstract type
In this situation:
class Base {
virtual void methodA() = 0;
virtual void methodB() = 0;
};
class Base_A : public Base {
void methodA();
void methodB();
};
class Base_B : public Base {
void methodA();
void methodB();
};
class MyClass {
private:
Base * b;
};
When compiling, it gives an error message:
error: cannot declare field MyClass::b to be of abstract type because the following virtual functions are pure within Base:
Base::methodA()
Base::methodB()
How to solve this?
UPDATE Now it compiles. I don't know what I changed.
+2
source to share