单项选择题
有以下程序:
#include<iostream>
using namespace std;
class MyClass
public:
MyClass(int n)number=n;
//拷贝构造函数
MyClass(MyClass&other) number=other.number;
~MyClass()
private:
int number;
;
MyClass fun(MyClass p)
MyClass temp(p);
return temp;
int main()
MyClass obj1(10),obj2(0);
MyClass obj3(obj1);
obj2=fun(obj3);
return 0;
程序执行时,MyClass类的拷贝构造函数被调用的次数是( )。
A.5
B.4
C.3
D.2
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
下面程序的输出结果是( )。 #include<iostream.h> Class example int a; public: example(int B.a=b++; void print()a=a+1 cout<<a<<““; void print()constcout<<a<<““; ; void main() example x(3); Const example y(2); x.print(); y.print();
A.2 2
B.4 3
C.4 2
D.3 2
点击查看答案&解析
单项选择题
类模板template<class T>class x…,其中友元函数f对特定类型T(如int),使函数f(x<int>)成为x<int>模板类的友元,则其说明为( )。
A.friend voidf();
B.friend voidf(x<T>);
C.friend voidA::f();
D.friend void C<T>::f(x<T>);
点击查看答案&解析
相关试题
下面程序的运行结果为( )。 #include...
有以下程序: #include<iostream> usi...
有以下程序: #include<iostream> usi...
下列函数的运行结果是( )。 #include...
下列程序的运行结果是( )。 #include...