swap function in array

closed account (G60iz8AR)
How do you find the swap function in this array ?

#include <iostream>
#include <string>
using namespace std;



int main ()
{
int x,y;
cout << "Enter a two small positive numbers: ";
cin >> x >> y;
cout << "Before swap: x=" << x << " y= " << y << endl;
// swap( x , y );
cout << "After swap: x=" << x << " y= " << y << endl;

return 0;
}


I see no array.

The function std::swap() is found in the algorithm library in C++98, or the utility library in C++11.

This means that you should:

1
2
#include <utility> // and if this doesn't work...
#include <algorithm> 


http://www.cplusplus.com/reference/algorithm/swap/
http://www.cplusplus.com/reference/utility/swap/
Topic archived. No new replies allowed.