Since std::string
in C++ is mutable you can use that. It has a += operator
and an append
function.
If you need to append numerical data use the std::to_string
functions.
If you want even more flexibility in the form of being able to serialise any object to a string then use the std::stringstream
class. But you'll need to implement your own streaming operator functions for it to work with your own custom classes.