Write a Program To Swap The Numbers Using The Concept Of Function Template
// function templates
#include <iostream>
using namespace std;
// Function template to swap
template <class T>
int swap_numbers(T& x, T& y)
{
T t;
t = x;
x = y;
y = t;
return 0;
}
// Driver code
int main()
{
int a, b;
cout<<"enter the two number";
cin>>a>>b;
// Invoking the swap()
swap_numbers(a, b);
cout << "a=" <<a<< " b="<< b << endl;
return 0;
}
Output