Answers for "how to swap values in c++"

C++
0

what did swap method return in c++

Return Value: The function does not return anything, it swaps the values of the two variables
Posted by: Guest on December-16-2020
-1

swap string c++

// swap strings
#include <iostream>
#include <string>

main ()
{
  std::string buyer ("money");
  std::string seller ("goods");

  std::cout << "Before the swap, buyer has " << buyer;
  std::cout << " and seller has " << seller << 'n';

  seller.swap (buyer);

  std::cout << " After the swap, buyer has " << buyer;
  std::cout << " and seller has " << seller << 'n';

  return 0;
}
Posted by: Guest on December-19-2020

Browse Popular Code Answers by Language