初始提交:String 与 Link

string =重载的返回的this
This commit is contained in:
youspectrum 2022-09-25 22:30:57 +08:00
parent 8395ba2b38
commit d797c2f62e
6 changed files with 11 additions and 8 deletions

Binary file not shown.

View File

@ -19,3 +19,5 @@
180 229 1664115743542209642 MSTL 5fce564c316cd3aa
0 181 1664115749406173515 CMakeFiles/MSTL.dir/main.cpp.o 134556d569115d52
181 230 1664115749454173219 MSTL 5fce564c316cd3aa
1 192 1664116226535223733 CMakeFiles/MSTL.dir/main.cpp.o 134556d569115d52
192 243 1664116226587223410 MSTL 5fce564c316cd3aa

Binary file not shown.

View File

@ -1,3 +1,3 @@
Start testing: Sep 25 22:22 CST
Start testing: Sep 25 22:30 CST
----------------------------------------------------------
End testing: Sep 25 22:22 CST
End testing: Sep 25 22:30 CST

View File

@ -1,12 +1,13 @@
#include <iostream>
#include "h/LinkList.h"
#include "h/String.h"
int main() {
Link *link = new Link;
link->add(6);
link->add(7);
link->add(8);
auto begin = link->begin();
std::cout << ++begin->data << std::endl;
String string("123456");
// 赋值 重载函数 返回了 *this
// 这使得以 目的值具有 对象的this
// 更改的值 不在函数内 而是申请的堆中
String str = string;
std::cout << str.get_c_str() << std::endl;
return 0;
}