#include <iostream.h>
#include<string.h>
#include<conio.h>
typedef const char PTR; // typedef of const char
// generic function template definition
template <class T>
T max(T x, T y)
{
return x>y ? x:y;
}
// template explicit specializatin
template<class T>
PTR max<PTR>(PTR str1, PTR str2)
{
if (strcmp (str1, str2) > 0)
return str1;
else
return str2;
}
int main()
{
float fv1=28.75, fv2 = -31.50, fv;
const char *cp;
fv = max (fv1, fv2); // max () is instantiated to float
cout<< "Maximum, = " <<fv<<endl;
cp = max ("good", "bad");
// explicit specialization instantiation
cout <<"String = " <<cp;
getch();
return 0;
}
SiteMap
|
Link Us
...Language...
English
French
German
Hindi
Italian
Russian
Japanese
Chinese
Home
|
About Us
|
Portfolio
|
Services
|
Career
|
Contact Us
|
Industrial Training
|
Achievement
Corporate Services
Web Design and development
Web Promotion (SEO)
Multimedia/CD Presentation
Software development
E.Commerce
Training@balujalabs
Software Courses
Hardware Courses
Networking.Courses
Mobile Repairing Courses
UGC Degrees
Student Corner
Programming & Projects
Placement Papers
Project Ideas
Synopsis Ideas
Franchise Section
Administrator
Franchise Inquiry
This program illustrates the function template explicit specialization.
1
This program creates a function template to find the square of a no. of type int and float.
2
This program is to define a function template to swap the contents of two data items of type int, float, and double.
3
This program illustrates the function templates instantiation.
4
This program illustrates the function template instantiation where the template parameter list contains both template type and template non-type parameters.
5
This program illustrates the template arguments with L value transformation.
6
This program illustrates the inclusion compilation model of the function template.
7
This program illustrates the function template explicit specialization.
8
This program illustrates the overloaded function templates.
9
This program illustrates the overloaded resolution of templates instantiation and an ordinary function call.
Home
|
About Us
|
Portfolio
|
Services
|
Career
|
Contact Us
|
Industrial Training
|
Achievement