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 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?