int a = 5, b = 10; std::swap(a, b); cout << "a = " << a << ", b = " << b << endl;
a = 10, b = 5
std::string str1 = "Hello"; std::string str2 = "World"; std::swap(str1, str2); cout << "str1 = " << str1 << ", str2 = " << str2 << endl;
str1 = World, str2 = Hello
int arr1[] = {1, 2, 3, 4, 5}; int arr2[] = {6, 7, 8, 9, 10}; std::swap(arr1, arr2); for (int i = 0; i < 5; i++) { cout << arr1[i] << " "; } cout << endl; for (int i = 0; i < 5; i++) { cout << arr2[i] << " "; }
6 7 8 9 10 1 2 3 4 5The std::swap function is implemented in the