单项选择题
有如下程序: #include<iostream> using namespace std; class A { public: A(){cout<<"A";} ~A(){cout<<"~A";) }; class B:public A { A*p; public: B(){cout<<"B";p=new A;} ~B(){cout<<"~B";delete p;} }; int main() { B obj; return 0; } 执行这个程序的输出结果是( )。
A.BAA~A~B~A
B.ABA~B~A~A
C.BAA~B~A~A
D.ABA~A~B~A
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
下列程序的执行结果是( )。 #include<iostream.h> class Sample { int x,y; public: Sample() {x=y=0;} Sample(int a,int b) {x=a;y=b;} ~Sample() { if(x==y) cout<< x=y <<end1; else cout<< x!=y <<end1; } void disp() { cout<< x= <<x<< ,y= <<y<<end1; } }; void main() { Sample s1(2,3); s1.disp(); }
A.x=2,y=2
B.x=3,y:3
C.x=2,y=3
D.x=3,y=2
点击查看答案&解析
单项选择题
下列程序将x,y和z按从小到大的顺序排列,请将下面的函数模板补充完整。 template<class T> void fun(______) { T a; if(x>y) { a=x; x=y;y=a; } if(y>z) { a=y; y=z;z=a; } if(x>y) { a=x; x=y;y=a; } }
A.T x,T y,T z
B.T x;y;z
C.T &x,T &y,T &Z
D.T &x,&y,&z
点击查看答案&解析
相关试题
已知下列程序的输出结果是23,请将横线处...
有如下程序:#include<iostream>using ...
多态性分为两类:编译时的多态性和____...
下面是一个栈类的模板,其中push函数将元素...
若,将一个二元运算符重载为类的成员函数,...