yo/stl/examples/insertcpp.cc
raw| 1 | #include <iostream> |
| 2 | #include <memory> |
| 3 | #include <cstring> |
| 4 | using namespace std; |
| 5 | |
| 6 | int main() |
| 7 | { |
| 8 | unique_ptr<string> sp{ new string{ "Hello world" } }; |
| 9 | |
| 10 | cout << *sp << '\n'; |
| 11 | sp->insert(strlen("Hello "), "C++ "); |
| 12 | cout << *sp << '\n'; |
| 13 | } |
| 14 | /* |
| 15 | Displays: |
| 16 | Hello world |
| 17 | Hello C++ world |
| 18 | */ |