首页 > 职业考试题库1 > 题目详情
有如下程序: #include using namespace std; cl
题目内容:
[单选题]有如下程序: include using namespace std; class B { public:有如下程序: #include <iostream> using namespace std; class B { public: virtual void show() { cout<<"B"; } }; class D: public B{ public: void show() { cout<<"D"; } }; void fun1(B *ptr) { ptr->show();} void fun2(B &ref) { ref. show();} void fun3(B b) {b.show();} int main() { B b,*p=new D; D d; fun1(p); fun2(b); fun3(d); return 0; }程序的输出结果是
A.BBB
B.BBD
C.DBB
D.DBD
有如下程序: #include <iostream> using namespace std; class B { public: virtual void show() { cout<<"B"; } }; class D: public B{ public: void show() { cout<<"D"; } }; void fun1(B *ptr) { ptr->show();} void fun2(B &ref) { ref. show();} void fun3(B b) {b.show();} int main() { B b,*p=new D; D d; fun1(p); fun2(b); fun3(d); return 0; }程序的输出结果是
A.BBB
B.BBD
C.DBB
D.DBD
本题链接: