Tuesday, October 14, 2008

PROGRAM TO IMPLEMENT FUNCTION TEMPLATES

#include
#include
#include

template
void swap1(t a,t b)
{
t temp;
temp=a;
a=b;
b=temp;
cout<}

void main()
{
int c,d;
float e,f;
char g,h;
clrscr();

cout<<"enter values :";
cin>>c>>d>>e>>f>>g>>h;
swap1(c,d);
swap1(e,f);
swap1(g,h);
getch();
}


Output :

enter values :2 3 4.5 6.7 a b
3 2 6.7 4.5 b a

No comments: