问答题
下列程序的执行结果是( )。
#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();
【参考答案】
C
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
下列程序的输出结果是( )。 #include<iostream> using namespace std; int main() char a[]= Hello,Test ; char *p=a; while(*p) if(*p>=’a’&&*p<=’’z’) cout<<char(*p+’A’-’a’); else cout<<*p; p++; return 0;
A.hello,test
B.Hello,Test
C.HELLO,TEST
D.hELLO,tEST
点击查看答案&解析
单项选择题
下列程序将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
点击查看答案&解析
相关试题
有如下程序: #include<iostream> usi...
下面是一个栈类的模板,其中push函数将元素...
已知下列程序的输出结果是42,请将横线处...
多态性分为两类:编译时的多态性和____...
若,将一个二元运算符重载为类的成员函数,...