Write a program of two values independent of the type of the variable using function template


 

/* Write a program of two values independent of the type of the variable using function template*/

#include<iostream.h>

#include<conio.h>

template<class t>

void sW.A.P.(t &m,t &n)

{

t temp;

temp=m;

m=n;

n=temp;

}

void main()

{

clrscr();

int a,b;

cin>>a>>b;

sW.A.P.(a,b);

cout<<“a=”<<a<<“\tb=”<<b;

float x,y;

cin>>x>>y;

sW.A.P.(x,y);

cout<<“x=”<<x<<“\ty=”<<y;

char c1,c2;

cin>>c1>>c2;

cout<<“c1=”<<c1<<“\t c2=”<<c2;

getch();

}

/* output:

5 10

a=10 b=5

2.5 5.75

x=5.75 y=2.5

r h

c1=r c2=h*/

Related Posts

Comments are closed.