主观

完成下面类中成员函数的定义。

#include ﹤iostream﹥

#include ﹤string﹥

using namespace std;

class str

{ private:

char * st;

public:

str(char *a)

{

set (a);

}_________ //运算符“=”重载函数

{

delete st;set(a.st);

return * this;

}

void show( )

{

cout ﹤﹤ st ﹤﹤ endl;

 }

~str( )

 { delete st; }

void set(char *s);

{

_________strcpy( st, s);

}

};

void main( );

{

str s1("hello"),

s2("world");

s1. show( ),

s2.show( );

s2=s1;

s1. show( ),

s2.show( );

}

参考答案
您可能感兴趣的试题
¥

订单号:

遇到问题请联系在线客服

订单号:

遇到问题请联系在线客服