Write a program to overload function template with non-function template


 

/* Write a program to overload function template with non-function template*/

#include<iostream.h>

#include<conio.h>

#include<string.h>

template<class t>

t min(t a,t b)

{

return(a<b)?a:b;

}

char *min(char *p,char *q)

{

int k=strcmp(p,q);

return(k<0)?p:q;

}

void main()

{

clrscr();

cout<<“\n min of 2integer number=”<<min(7,15);

cout<<“\n min of 2float number=”<<min(3.5,2.75);

cout<<“\n min of 2string=”<<min(“xyz”,”abc”);

getch();

}

/* output:

min of 2integer number=7

min of 2float number=2.75

min of 2string =abc*/

Related Posts

Comments are closed.