- Fix link resolution with proper relative/absolute path handling - Improve link styling with underline decoration - Hide leaf nodes from tree, only show directories - Fix log file path for packaged app
44 lines
1.1 KiB
Markdown
44 lines
1.1 KiB
Markdown
# String::operator+=
|
|
|
|
```cpp
|
|
String& operator+=(const String& other);
|
|
String& operator+=(const char* str);
|
|
String& operator+=(char c);
|
|
```
|
|
|
|
将指定的内容追加到当前 String 的末尾。
|
|
|
|
**参数:**
|
|
- `other` - 要追加的 String 对象
|
|
- `str` - 要追加的以 null 结尾的 C 字符串
|
|
- `c` - 要追加的单个字符
|
|
|
|
**返回:** `*this`,支持链式调用
|
|
|
|
**复杂度:** O(n),其中 n 为被追加内容的长度。可能会触发重新分配,但均摊复杂度为 O(1)。
|
|
|
|
**示例:**
|
|
```cpp
|
|
#include "XCEngine/Containers/String.h"
|
|
#include <iostream>
|
|
|
|
int main() {
|
|
XCEngine::Containers::String s("Hello");
|
|
|
|
s += XCEngine::Containers::String(" World"); // 追加 String
|
|
std::cout << s.CStr() << std::endl; // 输出: Hello World
|
|
|
|
s += "!"; // 追加 const char*
|
|
std::cout << s.CStr() << std::endl; // 输出: Hello World!
|
|
|
|
s += '?'; // 追加 char
|
|
std::cout << s.CStr() << std::endl; // 输出: Hello World!?
|
|
|
|
return 0;
|
|
}
|
|
```
|
|
|
|
## 相关文档
|
|
|
|
- [String 总览](string.md) - 返回类总览
|