Program to illustrate the concept of templates.

#include<iostream>
using namespace std;
template <class t>
void display(t x)
{
cout<<"Displaying function of template : "<<x<<endl;
}
void display(int x)
{
cout<<"Explicit Display function : "<<x<<endl;
}
int main()
{
display(200);
display(12.05);
display('a');
cout<<"\n/*\nName-Sanjampreet Singh\nRoll Number-1507967\n*/";
}

Output:

Comments

Post a Comment

Popular posts from this blog

To create an html page with frames and frameset

1. Write a program to insert a new element at end as well as at a given position in an array in Java

1. To familiarize with network devices like switch, hub, routers and bridges in LaTex