单项选择题
有以下程序 #include<iostream> using namespace std; class MyClass { public: MyClass(intn) {number=n;} //拷贝构造函数 MyClass (MyClass& other) {number=other.number;} ~MyClass(){} private: int number; }; MyClass fun (MyClass p) { MyClass temp(p); return temp; } intmain() { MyClass obj1(10),obj2(0); MyClass obj3(obj1); obj2=fun(obj3); return0; } 程序执行时,MyClass类的拷贝构造函数被调用的次数是
A.5
B.4
C.3
D.2
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
下列程序的输出结果是() #inClUde<iostream> using namespace std; intmain() { Char a[]= HellO,World ; Char*ptr=a; while(*ptr) { if(*ptr>=’a’&& *ptr <=’Z’) cout<<char(*ptr+’A’ -’a’); else cout<<*ptr; ptr++; } retur0; }
A、HELLO,WORLD
B、Hello,world
C、hELLO,wORLD
D、hellO,world
点击查看答案&解析
单项选择题
有以下类定义 classPoint{ public: Point(int x=0,int y=0){_x=x;_y=y;} void Move (int xOff,int yOff {_x +=xOff;_y+yOff} void Print() const {cout<<'('<<_x<<','<<_y<<')'<<endl;} private: int_x_y; }; 下列语句中会发生编译错误的是
A.Pointpt;pt;Print();
B.const Point pt;pPrint();
C.Pointpt;pMove(1,2);
D.const Point pt;pMove(1,2);
点击查看答案&解析
相关试题
有以下程序 #include<iostream> using...
有以下类定义 class MyClass { privat...