有下列程序,在横线添加; #include<iostream> using namespace std; class TestClass { public: TestClass (int n){number=n;} ______//拷贝构造函数 ~TestClass(){} private: int number; }; TestClass fun(TestClass p) { TestClass temp(P); return temp; } int main() { TestClsss obj1(10),obj2(0); TestClass obj3(obj1); obj2=fun(obj3); return 0; }
A.TestClass(TestClass &other){number=other.number;}
B.TestClass(TestClass other){number=other.number;}
C.TestClass(TestClass &other){number;}
D.TestClass(&other){number=other.number;}
第1题:
有下列程序: #include<iostream> using namespace std; class TestClass { public: virtual void fun1() { cout<<"fun1TestClass"; } virtual void fun2() { cout<<"fun2TestClass"; } }; class TeSt
A.fun1TeStClass1 fun2TeStClass
B.fun1TestClass1 fun2TestClass1
C.fun1TeStClass fun2TeStClass
D.fun1TestClaSSfun2TestClaSS1
第2题:
有下列程序: #include<iostream> using namespace std; class TestClass{ protected: TestClass(){cout<<'x';} TestClass(char c){cout<<c;} }; class TestClassl:public TestClass{ public: TestClassl(char c){cout<<c;}
A.y
B.yx
C.xy
D.yy
第3题:
下列程序的输出结果为2,横线处应添加语句( )。 #include<iostream> using namespace std; { public: ______void fun(){cout<<1;} }; class TestClass2:public TestClass1 { public:void fun(){cout<<2;) }; int main() { TestClass1 *p=new TestClass2; p->fun(); delete p; Teturn 0; }
A.public
B.private
C.virtual
D.protected
第4题:
有下列程序: #include<iostream> using namespace std; c1ass TestClass { private; char c; public: TestClass(char n):c(n){} ~TeStClass() { cout<<c } }; class TestClass1:public TestClass {
A.xy
B.yx
C.x
D.y
第5题:
有下列程序: #include<iostream> using namespace std; class TestClass { int a; public: TestClass(int x)<a=x;} void show(){cout<<a;} }; class TestClass1:publicTestClass { int b; public: TestCla
A.5
B.1
C.0
D.2