fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main(void) {
  7. string Drink = "A martini";
  8. string Needs = "Shaken, not stirred";
  9.  
  10. cout << Drink << ". " << Needs << "." << endl;
  11. Drink.swap(Needs);
  12. cout << Drink << ". " << Needs << "." << endl;
  13. return 0;
  14. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
A martini. Shaken, not stirred.
Shaken, not stirred. A martini.