class complex{
double real; // 实部
double imag; // 虚部
public:
complex(double x , double y){
real=x;
imag=y;
}
perator+(complex c){// 重载加法运算符 “ + ”
return complex(___________)
}
};
[主观题]有如下类定义,请将Sample类的复制构造函数补充完整。class Sample{public:Sample( ){ }~Sample( ){if(P)delete P;)Sample(const Sample&s){______}void SetData(int datA) {P=new int(datA) ;}private:int*P:};
[单选题]( 28 )若有如下类声明class My Class {public:MyClass () {cout<<1;}};执行下列语句MyClass a,b[2],*P[2];以后,程序的输出结果是A. ) 11B. ) 111C. ) 1111D. ) 11111
[单选题]有如下类声明: class TestClass int i; private:int j; protected:int k; public:int m,n; 其中,私有成员的数量为( )。A.0B.1C.2D.3
[单选题]有如下类的声明: class Base{ protected: int amount; public: Base(int n=0):amount(n){} int getAmount()const{return amount;} }; class Derived:public Base{ protected: int value public: Derived(int m,int n):value(m),Base(n){} int getData()const{return value+amou
[单选题]有如下类声明:class SAMPLE{int n;public:SAMPLE (int i = 0): n(i){}void setvalue(int n0);};下列关于 setvalue 成员函数的实现中,正确的是A. . SAMPLE::setvalue(int n0){n = n0;}B. . void SAMPLE::setvalue(int n0){n = n0;}C. . void setvalue(int n0){n = n0;}D. . setvalue(int n0){n
[试题]有如下类声明:class MyClass{int i;private: int j;protected:int k;public:int m, n;};其中,私有成员的数量为 ( 9 ) 。
[单选题]有如下类声明: class MyBASE{ int k; public: void set(iht n){k=n;} int get()coast{return k;} }; class MyDERIVED:pnoted My BASE { protected: int j; public: void set(int m,int n){MyBASE::set(m);j=n;} int get()const{return MyBASE::get()+j;} }; 则类MyDERIVED中保护的数据
[单选题]若有如下类声明class MyClass{public: MyClass(){cout<<1;}};执行下列语句MyClass a,b[2],*p[2];以后,程序的输出结果是A.11B.111C.1111D.11111
[单选题]有如下类声明: class SAMPLE { int n; public: SAMPLE(int i=0):n(i) { } void setValue(int nO); }; 下列关于getValue 成员函数的实现中,正确的是A.SAMPLE::setValue(int nO){ n=nO;}B.void SAMPLE::setValue(int nO){ n=nO;}C.void setValue(int nO){ n=nO;}D.(int nO){ n=nO;}
[单选题]有如下类声明: class TestClass { int n; public: TestClass(int i=0):n(i){} void setValue(int n0); }; 下面关于setValue成员函数的实现中,正确的是( )A.TestClass::setValue(int n0){n=n0;)B.void TestClass::setValue(int n0){n=n0;}C.void setValue(int n0){n=n0;}D.setValue(int n0){n=n