A-A+
下面程序的执行结果为 #include iostream using namespace
问题详情
下面程序的执行结果为 #include" iostream" using namespace std; class A { int a; public: void Seta(int x) { a=x;} void Display_a() { cout < < a < < end1;} }; class B { int b; public: void Setb(int x) { b=x;} void D
A.输出为2 2 3
B.有错误在第5行
C.输出为1 2 3
D.有错误在第7行请帮忙给出正确答案和分析,谢谢!
参考答案
正确答案:D
解析:pnvate继承不能调用Display_b函数,public继承可以调用基类中非pfivate成员。注意:类的继承方式public,protected和private的区别。