C++ examples for STL:string
Swapping strings
#include <iostream> #include <string> int main(int argc, const char* argv[]) { std::string first("one"); std::string second("two"); std::cout << "Before swap:\n first: " << first << "\nsecond: " << second; first.swap(second);// w w w . j a v a2 s.c om std::cout << "\n\nAfter swap:\n first: " << first << "\nsecond: " << second << std::endl; return 0; }