Ai
1 Star 0 Fork 0

Elio/C++

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test.cpp 642 Bytes
一键复制 编辑 原始数据 按行查看 历史
Elio 提交于 2023-05-07 11:04 +08:00 . string类模拟实现
#define _CRT_SECURE_NO_WARNINGS 1
#include "mystring.h"
//using namespace wzh;
int main()
{
wzh::mystring s1("apple");
wzh::mystring s2(s1);
wzh::mystring s3;
wzh::mystring::iterator it = s1.begin();
while (it != s1.end())
{
cout << *it++ << ' ';
}
cout << endl;
s1.push_back('x');
cout << s1 << endl;
s1.append("bear");
cout << s1 << endl;
s1 += "KKK";
cout << s1 << endl;
for (auto e : s1)
{
cout << e << ' ';
}
cout << endl;
cout << s1.insert(0, 'p') << endl;
cout << s1.insert(3, "TTT") << endl;
cout << s1.erase(0, 1) << endl;
cout << s1.erase(2, 1) << endl;
cout << s1.insert(0, "YYY") << endl;
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zhihao_code/cplusplus.git
git@gitee.com:zhihao_code/cplusplus.git
zhihao_code
cplusplus
C++
master

搜索帮助