I have an abstract graph (A
in the example). And it has inner-class InnerA
which is used for one of the functions. I want to derive a new class (e.g. B
) from this class and make a wrapper around InnerA
to add a new field that should be used in B
.
class A {
public:
class InnerA {};
virtual void function(InnerA) = 0;
};
class B : public A {
public:
class InnerB : InnerA {
public:
int new_field = 0;
};
void function(InnerB b) override {
b.new_field = 1;
}
};
But I receive an error that function
in B
cannot override the base function. What is the right way to implement this?
error: 'void B::function(B::InnerB)' marked 'override', but does not override
void function(InnerB b) override {
^~~~~~~~