单项选择题
有如下程序:
#include<iostream>
using namespace std;
class Base
public:
Base(int x=0)cout<<x;
;
class Derived:public Base
public:
Derived(int x=0)cout<<x;
private:
Base val;
;
int main()
Derived d(1);
return 0;
程序执行后的输出结果是( )。
A.100
B.000
C.010
D.001
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
有如下四个语句: ①cout<<’A’<<setfill(’*’)<<left<<setw(7)<<’B’<<endl: ②cout<<setfill(’*’)<<left<<setw(7)<<’A’<<’B’<<endl; ③cout<<’A’<<serfill(’*’)<<right<<setw(7)<<’B’<<endl; ④cout<<setfill(’*’)<<right<<setw(7)<<’A’<<’B’<<endl; 其中能显示A******B的是( )。
A.①和③
B.①和④
C.②和③
D.②和④
点击查看答案&解析
单项选择题
有如下程序: #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> usi...
下面程序的输出结果是( )。 #include...
有以下程序: #include<iostream> usi...
有以下程序: #include<iostream> usi...
下列程序中横线处应填入的语句是( )。 ...