填空题
有如下类定义,请将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:
;
【参考答案】
*this=s;
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
如下程序的输出结果是______。 #include<iostream> using namespace std; class Pet char name[10]; public: Pet(char*nanle)strcpy(this->name,name); const char*getName( )constreturn name; virtual void call( )eonst=0; ; class Dog:public Pet public: Dog(char*name):Pet(name) void call( )eonstcout<< 汪汪叫 ; ; class Cat:public Pet public: Cat(char*name):Pet(name) void call( )consteout<< 喵喵叫 ; ; int main( ) Pet*petl=new Dog( 哈克 ),*pet2=new Cat( 吉米 ); eout<<petl->getName( );petl->call( );eout<<endl; cout<<pet2->getName( );pet2->call( );eout<<endl; return 0;
点击查看答案&解析
填空题
如下程序的输出结果是______。 #include<iostream> using namespace std; class Wages “工资”类 double base; 基本工资 double bonus; 奖金 double tax; 税金 public: Wages(double CBase,double CBonus,doable CTax): base(CBase),bonus(CBonus),tax(CTax) double getPay( )const; 返回应付工资额 Wages operator+(Wages w)cons[; 重载加法 ; double Wages::getPay( )cons[return base+bonus-tax; Wages Wages::operator+(Wages w)constreturn Wages(base+w.base,bonus+w.bonus,tax+w.tax); int main( ) Wages wl(2000,500,100),w2(5000,1000,300); eout<<(wl+w2).getPay( )<<endl; return 0;
点击查看答案&解析
相关试题
有如下程序: #include<iostreanl> us...
如下程序的输出结果是 #include<iostrea...
请在下列程序中的空格处填写正确的语句: ...
下列关于模板的叙述中,错误的是
有3个关系R、S和T如下: 由关系R和S通过...