I have a const std::string to which I want to append another string. But since it's constant, I can't alter it directly; I'll have to copy it to another string somehow. How do I do this?
You just have to create another string:
const std::string str = "Hello";
std::string other = str + ", world!";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.