程序填空题:B Fill in the blanks
Run the following program, the output is: B::f()
```c++
#include
using namespace std;
class A{
public:
@@[virtual void f()](1){ cout<<"A::f()\n"; }
};
class B:public A{
public:
void f() {cout<<"B::f()\n"; }
};
int main()
{
B b;
A &p @@[=b](1);
@@[p.](1)f();
return 0;
}
```
答案:
第1空:virtual void f()
第2空:=b
第3空:p.
```c++
#include
using namespace std;
class A{
public:
@@[virtual void f()](1){ cout<<"A::f()\n"; }
};
class B:public A{
public:
void f() {cout<<"B::f()\n"; }
};
int main()
{
B b;
A &p @@[=b](1);
@@[p.](1)f();
return 0;
}
```
答案:
第1空:virtual void f()
第2空:=b
第3空:p.