C++ examples for STL:string
Set the capacity of str4 to 128.
#include <iostream> #include <string> using namespace std; int main()/*w w w .java 2 s .c o m*/ { string str1("Alpha"); string str2("Beta"); string str3("Gamma"); string str4; str4 = str1 + str3; cout << "Setting the capacity of str4 to 128\n"; str4.reserve(128); cout << "Capacity of str4 is now: " << str4.capacity() << "\n\n"; return 0; }