View Single Post
Old 06-29-2005, 04:45 AM   #7 (permalink)
Rashakil Fol
Registered User
 
Join Date: Jun 2005
Posts: 3
Rashakil Fol is on a distinguished road
Ironically, strings include their own swap method which is much more efficient -- it takes a constant time of operation instead of copying every character. For example:

Code:
std::string a = "Alpha";
std::string b = "Beta";
a.swap(b);
std::cout << a << ' ' << b << std::endl;
This prints Beta Alpha.
Rashakil Fol is offline   Reply With Quote