Suppose I have a base class foo
class foo {
virtual int get() const = 0;
}
and maybe 20 sub-classes foo_1, foo_2 ... inherited from foo and in the form of:
class foo_1 : public foo {
int get() const { return 1; }
}
...
class foo_20 : public foo {
int get() const { return 20; }
}
Suddenly life is not so easy! I have a class foo_21, which has to do this:
class foo_21 : public foo {
int get() { member_ = false; return 0; }
bool member_;
}
The problem is get is declared as const in the base class, and I have to change something in the sub-class foo_21. How could I find a way to go around it?
class foo, because you've missedvirtual).foo_21; butfoo_21::getdoesn't overridefoo::get.