问答题
有下列程序:
#include<iostream>
using namespace std;
classTest
public:
Test() n+=2;
~Test() n-=3;
static int getNum()return n;
private:
static int n;
;
int Test::n=1;
int main()
Test*p=new Test;
delete p;
cout<<"n="<<Test::getNum()<<endl;
retum 0;
执行后的输出结果是( )。
【参考答案】
A
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
有下列的程序: #include<cstring.h> #include<iostream.h> using namespace std; class MyString public: MyString(const char*s); ~MyString()<delete[]data; protected: unsigned len; char*data; ; MyString∷MyString(const char*s) len=strlen(S); data=new char[1en+1); strcpy(data,s); int main() MyString a( C++Programing ); MyString b(
A.;
return 0;
在运行上面的程序时出错,出错的原因是( )。A) 构造函数的实参不允许是本类的对象
B.没有定义实现深层复制(深拷贝)的复制构造函数
C.构造对象a时实参与形参类型不符
D.系统不能生成默认的复制构造函数
点击查看答案&解析
单项选择题
下列程序的输出结果是( )。 #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++; retum 0;
A.hllo,test
B.Hello,Test
C.HELLO,TEST
D.hELLO,tEST
点击查看答案&解析
相关试题
有下列程序: #include<iostream> usi...
如果表达式x=y*z中的“*”是作为成员函...
重新定义标识符的作用域规定是外层变量被隐...
请定义一个函数名为fun,返回值为int,没有...
对于派生类的构造函数,在定义对象时构造函...