初始提交:String 与 Link
string =重载的返回的this
This commit is contained in:
parent
8395ba2b38
commit
d797c2f62e
Binary file not shown.
@ -19,3 +19,5 @@
|
|||||||
180 229 1664115743542209642 MSTL 5fce564c316cd3aa
|
180 229 1664115743542209642 MSTL 5fce564c316cd3aa
|
||||||
0 181 1664115749406173515 CMakeFiles/MSTL.dir/main.cpp.o 134556d569115d52
|
0 181 1664115749406173515 CMakeFiles/MSTL.dir/main.cpp.o 134556d569115d52
|
||||||
181 230 1664115749454173219 MSTL 5fce564c316cd3aa
|
181 230 1664115749454173219 MSTL 5fce564c316cd3aa
|
||||||
|
1 192 1664116226535223733 CMakeFiles/MSTL.dir/main.cpp.o 134556d569115d52
|
||||||
|
192 243 1664116226587223410 MSTL 5fce564c316cd3aa
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -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
|
||||||
|
13
main.cpp
13
main.cpp
@ -1,12 +1,13 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "h/LinkList.h"
|
#include "h/LinkList.h"
|
||||||
|
#include "h/String.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
Link *link = new Link;
|
String string("123456");
|
||||||
link->add(6);
|
// 赋值 重载函数 返回了 *this
|
||||||
link->add(7);
|
// 这使得以 目的值具有 对象的this
|
||||||
link->add(8);
|
// 更改的值 不在函数内 而是申请的堆中
|
||||||
auto begin = link->begin();
|
String str = string;
|
||||||
std::cout << ++begin->data << std::endl;
|
std::cout << str.get_c_str() << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user