91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 481KB
    文件類型: .zip
    金幣: 1
    下載: 0 次
    發布日期: 2021-01-09
  • 標簽: c++??dev??

資源簡介

C++的一般編譯器都定義和封裝了字符串功能,模仿定義string類的實現,可以實現并支持如下功能: (1)賦值(2)拷貝構造 (3)重載“=” (4)m.legnth() 函數測量字符串的長度 (5)m.cat(string const &)連接字符串

資源截圖

代碼片段和文件信息

#include
using?namespace?std;
class?str{
?char?*s;
?int?lenth;
public:
str(){s=new?char;}
str(const?str&p);
str(const?char?*p);
~str();
void?print();
int?legnth();
str&?operator=(const?str?&p);
str&?cat(str?const&?p);
};
str&?str::operator=(const?str?&p){
if(this==&p)?{return?*this;}
delete?[]s;s=0;
int?i=0;while(*(p.s+i)!=‘\0‘)i++;
lenth=i;
s=new?char[lenth+1];
for(int?j=0;j???????s[j]=p.s[j];
???s[lenth]=‘\0‘;
???return?*this;
}
str&?str::cat(str?const&?p){
char?*news=new?char[lenth+p.lenth+1];
for(int?i=0;i news[i]=s[i];
for(int?i=0;i news[lenth+i]=p.s[i];
news[lenth+p.lenth+1]=‘\0‘;
s=news;
lenth=lenth+p.lenth;
return?*this;
}
str::~str(){
if(s==NULL)
return;
delete[]s;

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-05-16?07:44??字符串\
?????文件????????1563??2018-05-09?15:47??字符串\syx3.cpp
?????文件?????1982440??2018-05-16?07:44??字符串\syx3.exe

評論

共有 條評論