sre*_*ree 3 c++ virtual inheritance optional-arguments
为什么这种印刷23作为输出; 我的期望是33.有人可以对此有所了解.
struct A {
virtual void f() {cout << "1";}
};
/* Private inheritance */
struct B : private A {
void f(int x = 0) {cout << "2";}
};
struct C : B {
void f(){cout << "3";}
};
int main() {
C obj;
B &ref = obj;
ref.f();
obj.f();
}
Run Code Online (Sandbox Code Playgroud)
struct中的f(int x = 0)方法B不与Anor C结构的f()方法共享签名.
| 归档时间: |
|
| 查看次数: |
852 次 |
| 最近记录: |