From Schmid.wiki
Jump to: navigation, search

Strings

The object-oriented way of generating new strings would be something like this:

#include <sstream>
#include <iostream> // for cout
using namespace std;

ostringstream o; 
o << 4 << "KB"; 
cout << o.str() << endl;
o.str(""); // reinitialize string
o << "something";
cout << o.str() << endl;

Outputs:

4KB
something