1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <iostream>
using namespace std;
void swapA(int &x, int &y);
void swapB(double &x, double &y);
void swapC(char &x, char &y);
int main()
{
int a = 5;
int b = 7;
cout << "Before swap, value of a :" << a << endl;
cout << "Before swap, value of b :" << b << endl;
swap(a, b);
cout << "After swap, value of a :" << a << endl;
cout << "After swap, value of b :" << b << endl;
/*************************************************/
cout << endl;
double c = 100;
double d = 450;
cout << "Before swap, value of c :" << c << endl;
cout << "Before swap, value of d :" << d << endl;
swap(c, d);
cout << "After swap, value of c :" << c << endl;
cout << "After swap, value of d :" << d << endl;
/*************************************************/
cout << endl;
char First = 27;
char Second = 72;
cout << "Before swap, value of First :" << int(First) << endl;
cout << "Before swap, value of Second :" << int(Second) << endl;
swap(First, Second);
cout << "After swap, value of First :" << int(First) << endl;
cout << "After swap, value of Second :" << int(Second) << endl;
system("pause");
return 0;
}
|