假设有 2 个结构A和B(B继承自A)。有A一个方法fin 被覆盖B。在内部覆盖时f,B我想使用f覆盖之前的方法。我怎样才能做到这一点?
f下面代码中的函数B应该返回,x * 2即 4.
struct A {
int x = 2;
int f() {
return x;
}
};
struct B : public A {
int f() {
return *f до переопределения*() * 2;
}
};