A-A+

有如下程序 #include<iostream> using namespace std;

2022-08-06 03:14:37 问答库 阅读 175 次

问题详情

有如下程序 #include<iostream> using namespace std; class GA{ public: virtual int f() {return 1;} }; class GB:public GA{ public: virtual int f() {return 2;} }; void show(GA g){cout<<g.f();} void display(GA&g){cout<<g.f();} int main() { GA a;show(A) ;display(A) ; GB b;show(B) ;display(B) ; return 0; }运行时的输出结果是
A.1111
B.1211
C.1112
D.1212请帮忙给出正确答案和分析,谢谢!

参考答案

正确答案:C

考点:程序