SlideShare a Scribd company logo
1 of 17
TEMPLATES
IN
C++
K.THAMIZHSELVI
Asst. Prof. of Computer Science
Bon Secours college for Women,
Thanjavur
TEMPLATES
• Template is a new concept allow the function or class
to work on more than one data type at once without
writing different codes for different data types.
• The parameters used during its definition is of generic
type and can be replaced later by actual parameter.
• This is called the concept of generic programming
• The templates are also called as parameterized classes
or functions.
Purpose of Templates
• Used in large programs
• Code reusability
• Time saving
• Flexibility of program
• Used to create a family of classes or functions.
Types of Templates
• 2 types:
– Class Template
– Function Template
Class Templates
• A Class Template can represent various similar
classes operating on different data types.
Syntax:
template < class T1, class T2,…>
class classname
{
functions;
};
Eg:
template <class T>
class vector
{
T* v;
int size;
public:
vector (int m)
{
v = new T [size = m];
for ( int i = 0; i <size; i++)
v[i] = 0;
}
vector ( T* a)
{
for ( int i = 0; i <size; i++)
v[i] = a[i];
}
T operator* (vector &y)
{
T sum = 0;
for ( int i = 0; i <size; i++)
sum + = this -> v[i] * y . V [i];
return sum;
}
};
Template class
• A class created from a class template is called
a Template class.
classname < type> objectname (arglist);
• The process of creating a specific class from
class template is called Instantiation.
Class Templates with Multiple Parameters
• More than one generic data types can be used
in a class template.
• They can be declared by comma separated list
within the template specification.
template < class T1, class T2, …..>
class classname
{
………
body of the class
………
};
Example:
template <class T1, class T2>
Class Test
{
T1 a;
T2 b;
public :
Test (T1 x, T2 y)
{
a = x;
b = y;
}
void show()
{
cout<< a << “ and “ << b << “n”;
}
};
int main()
{
cout<< “Instantiating the class template test1:”;
Test < float, int > test1 (1.23, 123);
test1.show();
cout<< “Instantiating the class template test2:”;
Test < int, char > test2 (100, ‘w’);
test2.show();
return 0;
}
Output for the Program
Instantiating the class template test1: 1.23 and 123
Instantiating the class template test2: 100 and w
Function Templates
• Function templates used to create a family of
functions with different argument types.
Syntax:
Template < class T>
returntype functionname (arguments of type T)
{
body of the function
}
Example
template < class T>
void swap ( T &x, T &y)
{
T temp = x;
x = y;
y = temp;
}
Function Template With Multiple Parameters
Syntax:
template < class T1, class T2,….>
returntype functionname(arguments of types T1,T2,..)
{
body of the function
}
Example:
template < class T1, class T2>
void display ( T1 x, T2 y)
{
cout << x “ “ << y << “n”;
}
int main()
{
cout << “calling function template with integer and character
string type parameters…n”;
display( 2000, “ECG”);
cout << “calling function template with float and integer type
parameters…n”;
display( 2.12, 212);
return 0;
}
Output
calling function template with integer and
character string type parameters…
2000 ECG
calling function template with integer and
character string type parameters…
2.12 212
Templates in c++

More Related Content

What's hot

Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++Janki Shah
 
Exception handling in c++
Exception handling in c++Exception handling in c++
Exception handling in c++imran khan
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT03062679929
 
11 constructors in derived classes
11 constructors in derived classes11 constructors in derived classes
11 constructors in derived classesDocent Education
 
Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend classAbhishek Wadhwa
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c languagetanmaymodi4
 
virtual function
virtual functionvirtual function
virtual functionVENNILAV6
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handlingkamal kotecha
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Vineeta Garg
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++HalaiHansaika
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Vishal Patil
 
Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++Sujan Mia
 

What's hot (20)

Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++
 
Exception handling in c++
Exception handling in c++Exception handling in c++
Exception handling in c++
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Encapsulation C++
Encapsulation C++Encapsulation C++
Encapsulation C++
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
11 constructors in derived classes
11 constructors in derived classes11 constructors in derived classes
11 constructors in derived classes
 
Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend class
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
 
virtual function
virtual functionvirtual function
virtual function
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Input output streams
Input output streamsInput output streams
Input output streams
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++
 

Similar to Templates in c++ (20)

Templates c++ - prashant odhavani - 160920107003
Templates   c++ - prashant odhavani - 160920107003Templates   c++ - prashant odhavani - 160920107003
Templates c++ - prashant odhavani - 160920107003
 
Object Oriented Programming using C++ - Part 5
Object Oriented Programming using C++ - Part 5Object Oriented Programming using C++ - Part 5
Object Oriented Programming using C++ - Part 5
 
templates.ppt
templates.ppttemplates.ppt
templates.ppt
 
Templates2
Templates2Templates2
Templates2
 
Templates presentation
Templates presentationTemplates presentation
Templates presentation
 
Templates1
Templates1Templates1
Templates1
 
2CPP15 - Templates
2CPP15 - Templates2CPP15 - Templates
2CPP15 - Templates
 
Class template
Class templateClass template
Class template
 
c++ Unit III - PPT.pptx
c++ Unit III - PPT.pptxc++ Unit III - PPT.pptx
c++ Unit III - PPT.pptx
 
Template C++ OOP
Template C++ OOPTemplate C++ OOP
Template C++ OOP
 
C++ Templates. SFINAE
C++ Templates. SFINAEC++ Templates. SFINAE
C++ Templates. SFINAE
 
Presentation 3rd
Presentation 3rdPresentation 3rd
Presentation 3rd
 
C#2
C#2C#2
C#2
 
Data structures and algorithms lab2
Data structures and algorithms lab2Data structures and algorithms lab2
Data structures and algorithms lab2
 
template c++.pptx
template c++.pptxtemplate c++.pptx
template c++.pptx
 
Types, classes and concepts
Types, classes and conceptsTypes, classes and concepts
Types, classes and concepts
 
Introduction to objective c
Introduction to objective cIntroduction to objective c
Introduction to objective c
 
59_OOP_Function Template and multiple parameters.pptx
59_OOP_Function Template and multiple parameters.pptx59_OOP_Function Template and multiple parameters.pptx
59_OOP_Function Template and multiple parameters.pptx
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 

More from ThamizhselviKrishnam

More from ThamizhselviKrishnam (11)

Standard template library
Standard template libraryStandard template library
Standard template library
 
Operators and expression in c++
Operators and  expression in c++Operators and  expression in c++
Operators and expression in c++
 
Functions, classes & objects in c++
Functions, classes & objects in c++Functions, classes & objects in c++
Functions, classes & objects in c++
 
Page maker - working with text
Page maker - working with textPage maker - working with text
Page maker - working with text
 
Microprocessor & architecture
Microprocessor & architectureMicroprocessor & architecture
Microprocessor & architecture
 
Instruction set of 8085
Instruction set of 8085Instruction set of 8085
Instruction set of 8085
 
Memory and storage devices
Memory and storage devicesMemory and storage devices
Memory and storage devices
 
Generations of computer
Generations of computerGenerations of computer
Generations of computer
 
Adobe Pagemaker 7.0
Adobe Pagemaker 7.0Adobe Pagemaker 7.0
Adobe Pagemaker 7.0
 
classification of digital computer
classification of digital computerclassification of digital computer
classification of digital computer
 
Pagemaker
PagemakerPagemaker
Pagemaker
 

Recently uploaded

Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
Transposable elements in prokaryotes.ppt
Transposable elements in prokaryotes.pptTransposable elements in prokaryotes.ppt
Transposable elements in prokaryotes.pptArshadWarsi13
 
TOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsTOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsssuserddc89b
 
Scheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxScheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxyaramohamed343013
 
Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |aasikanpl
 
Analytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdfAnalytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdfSwapnil Therkar
 
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxMicrophone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxpriyankatabhane
 
Artificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PArtificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PPRINCE C P
 
Manassas R - Parkside Middle School 🌎🏫
Manassas R - Parkside Middle School 🌎🏫Manassas R - Parkside Middle School 🌎🏫
Manassas R - Parkside Middle School 🌎🏫qfactory1
 
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
BUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdf
BUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdfBUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdf
BUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdfWildaNurAmalia2
 
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.aasikanpl
 
Twin's paradox experiment is a meassurement of the extra dimensions.pptx
Twin's paradox experiment is a meassurement of the extra dimensions.pptxTwin's paradox experiment is a meassurement of the extra dimensions.pptx
Twin's paradox experiment is a meassurement of the extra dimensions.pptxEran Akiva Sinbar
 
Pests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdfPests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdfPirithiRaju
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Patrick Diehl
 
Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdfPests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdfPirithiRaju
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxkessiyaTpeter
 
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...lizamodels9
 
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxLIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxmalonesandreagweneth
 

Recently uploaded (20)

Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
Transposable elements in prokaryotes.ppt
Transposable elements in prokaryotes.pptTransposable elements in prokaryotes.ppt
Transposable elements in prokaryotes.ppt
 
TOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsTOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physics
 
Scheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxScheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docx
 
Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |
 
Analytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdfAnalytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdf
 
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxMicrophone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
 
Artificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PArtificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C P
 
Manassas R - Parkside Middle School 🌎🏫
Manassas R - Parkside Middle School 🌎🏫Manassas R - Parkside Middle School 🌎🏫
Manassas R - Parkside Middle School 🌎🏫
 
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
 
Volatile Oils Pharmacognosy And Phytochemistry -I
Volatile Oils Pharmacognosy And Phytochemistry -IVolatile Oils Pharmacognosy And Phytochemistry -I
Volatile Oils Pharmacognosy And Phytochemistry -I
 
BUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdf
BUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdfBUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdf
BUMI DAN ANTARIKSA PROJEK IPAS SMK KELAS X.pdf
 
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
 
Twin's paradox experiment is a meassurement of the extra dimensions.pptx
Twin's paradox experiment is a meassurement of the extra dimensions.pptxTwin's paradox experiment is a meassurement of the extra dimensions.pptx
Twin's paradox experiment is a meassurement of the extra dimensions.pptx
 
Pests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdfPests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdf
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?
 
Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdfPests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
 
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
 
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxLIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
 

Templates in c++

  • 1. TEMPLATES IN C++ K.THAMIZHSELVI Asst. Prof. of Computer Science Bon Secours college for Women, Thanjavur
  • 2. TEMPLATES • Template is a new concept allow the function or class to work on more than one data type at once without writing different codes for different data types. • The parameters used during its definition is of generic type and can be replaced later by actual parameter. • This is called the concept of generic programming • The templates are also called as parameterized classes or functions.
  • 3. Purpose of Templates • Used in large programs • Code reusability • Time saving • Flexibility of program • Used to create a family of classes or functions.
  • 4. Types of Templates • 2 types: – Class Template – Function Template
  • 5. Class Templates • A Class Template can represent various similar classes operating on different data types. Syntax: template < class T1, class T2,…> class classname { functions; };
  • 6. Eg: template <class T> class vector { T* v; int size; public: vector (int m) { v = new T [size = m]; for ( int i = 0; i <size; i++) v[i] = 0; } vector ( T* a) { for ( int i = 0; i <size; i++) v[i] = a[i]; } T operator* (vector &y) { T sum = 0; for ( int i = 0; i <size; i++) sum + = this -> v[i] * y . V [i]; return sum; } };
  • 7. Template class • A class created from a class template is called a Template class. classname < type> objectname (arglist); • The process of creating a specific class from class template is called Instantiation.
  • 8. Class Templates with Multiple Parameters • More than one generic data types can be used in a class template. • They can be declared by comma separated list within the template specification. template < class T1, class T2, …..> class classname { ……… body of the class ……… };
  • 9. Example: template <class T1, class T2> Class Test { T1 a; T2 b; public : Test (T1 x, T2 y) { a = x; b = y; } void show() { cout<< a << “ and “ << b << “n”; } };
  • 10. int main() { cout<< “Instantiating the class template test1:”; Test < float, int > test1 (1.23, 123); test1.show(); cout<< “Instantiating the class template test2:”; Test < int, char > test2 (100, ‘w’); test2.show(); return 0; }
  • 11. Output for the Program Instantiating the class template test1: 1.23 and 123 Instantiating the class template test2: 100 and w
  • 12. Function Templates • Function templates used to create a family of functions with different argument types. Syntax: Template < class T> returntype functionname (arguments of type T) { body of the function }
  • 13. Example template < class T> void swap ( T &x, T &y) { T temp = x; x = y; y = temp; }
  • 14. Function Template With Multiple Parameters Syntax: template < class T1, class T2,….> returntype functionname(arguments of types T1,T2,..) { body of the function }
  • 15. Example: template < class T1, class T2> void display ( T1 x, T2 y) { cout << x “ “ << y << “n”; } int main() { cout << “calling function template with integer and character string type parameters…n”; display( 2000, “ECG”); cout << “calling function template with float and integer type parameters…n”; display( 2.12, 212); return 0; }
  • 16. Output calling function template with integer and character string type parameters… 2000 ECG calling function template with integer and character string type parameters… 2.12 212