Write a program to create a function template with two genric data type


 

/* Write a program to create a function template with two genric data type*/

#include<iostream.h>

#include<conio.h>

template<class t1, class t2>

void display(t1 a,t2 b)

{

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

}

void main()

{

clrscr();

int i=10;

float f=2.5;

display(i,f);

char ch=’b’;

i=20;

display(ch,i);

getch();

}

/* output:

a=10 b=25.5

a=b b=20*/

Related Posts

Comments are closed.