AAAbloom 2016-11-03 12:09 采纳率: 0%
浏览 863

求解这个简单c++作业,嗯有很多错!

include
#include
class MString{
char *s;
int len;
public:
MStirng();
MString(char *ps);
MString(const MString &t);//copy funcation
~MString();
int size();
void swap(MString &t);
void find(char);
void find(MString &t);
MString &strcats(MString& t);
MString &strcpys(MString& t);
};
MString& MString::strcats(MString& t){
char *p;
p=new char[len+t.len+1];
strcpy(p,s);
strcat(p,t.s);
delete[]s;
s=p;
len+=t.len;
return *this;}
MString& Mstring::strcpys(MString& t){
s[1]=strcpy(s[0]);
}
MString::~MString()
int MString::size(int len){
for(int i=0; i<*s;i++);
cout<<s[i]<<" ";
}
void MString::find(char){
if(s.find(s[1])!=-1)
count <<"find"<<s[0]<<endl;
}
void MString::swap(MString &t){
s[0].swap(s[1]);
}
int main{
MString t("I am a student","teacher")
MString p=s;
}

}

  • 写回答

2条回答 默认 最新

  • threenewbee 2016-11-03 12:51
    关注

    s[1]=strcpy(s[0]);
    ->
    strcpy(s[0], t.s[0]);
    return &this;

    MString t("I am a student","teacher")
    ->
    MString t("I am a student","teacher");

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器