Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

Program to swap two numbers using class template.

#include<iostream.h>
#include<conio.h>
template <class T>
void swap(T x,T y)
{
T temp=x;
x=y;
y=temp;
}
void fun(int m,int n,float a,float b)
{
cout<<"Value of m & n before swap is: "<<m<<"\t"<<n;
swap(m,n);
cout<<"\n Value of m & n agter swap is: "<<m"\t"<<n;
cout<<"\n Value of a & b before swap is: "<<a<<"\t"<<b;
swap(a,b);
cout<<"\n Value of a & b after swap: "<<a<<"\t"<<b;
}
int main()
{
clrscr();
fun(100,200,12.4,13.4);
return 0;
}
 Output


Previous
Next Post »

1 comments:

Write comments
Abhishek
AUTHOR
February 21, 2020 at 1:55 AM delete

your question are using class template then why did you use the function template

Reply
avatar