SlideShare a Scribd company logo
1 of 11
SESSION โ€“ (2022-23)
A Seminar
on
โ€œTemplatesโ€
Oopโ€™s concept in c++
Guided by : Presented by :
Md. Afroj Ansari Sanju Sanjeev Toppo
(Ass. Professor of cs) Msc.cs II-semester
Roll no : 09
Date : 18/05/2023
โ€ข Template 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
TEMPLATES
โ€ข Used in large programs
โ€ข Code reusability
โ€ข Time saving
โ€ข Flexibility of program
Purpose of Templates
โ€“Class Template
โ€“Function Template
Types of Templates
โ€ข A Class Template can represent various similar
classes operating on different data types.
Syntax:
template < class T1, class T2,โ€ฆ>
class classname
{
functions;
};
Class Templates
โ€ข 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.
Template class
โ€ข 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
โ€ฆโ€ฆโ€ฆ
};
Class Templates with Multiple Parameters
โ€ข 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
}
Function Templates
template < class T>
void swap ( T &x, T &y)
{
T temp = x;
x = y;
y = temp;
}
Example
Syntax:
template < class T1, class T2,โ€ฆ.>
returntype functionname(arguments of types T1,T2,..)
{
body of the function
}
Function Template With Multiple
Parameters
template c++.pptx

More Related Content

Similar to template c++.pptx

Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
Prageeth Sandakalum
ย 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
Gaurav Tyagi
ย 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
RaazIndia
ย 

Similar to template c++.pptx (20)

JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
ย 
Function template
Function templateFunction template
Function template
ย 
33c
33c33c
33c
ย 
Oopsinphp
OopsinphpOopsinphp
Oopsinphp
ย 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
ย 
Object Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperObject Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft Developer
ย 
OOPJ.pptx
OOPJ.pptxOOPJ.pptx
OOPJ.pptx
ย 
OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
ย 
OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
ย 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
ย 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1
ย 
General oop concept
General oop conceptGeneral oop concept
General oop concept
ย 
B.sc CSIT 2nd semester C++ Unit7
B.sc CSIT  2nd semester C++ Unit7B.sc CSIT  2nd semester C++ Unit7
B.sc CSIT 2nd semester C++ Unit7
ย 
Basic concepts of oops
Basic concepts of oopsBasic concepts of oops
Basic concepts of oops
ย 
Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)
ย 
Static and dynamic polymorphism
Static and dynamic polymorphismStatic and dynamic polymorphism
Static and dynamic polymorphism
ย 
Static and dynamic polymorphism
Static and dynamic polymorphismStatic and dynamic polymorphism
Static and dynamic polymorphism
ย 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
ย 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
ย 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptx
ย 

More from SANJUSANJEEVTOPPO

C language.pptx
C language.pptxC language.pptx
C language.pptx
SANJUSANJEEVTOPPO
ย 
binary tree.pptx
binary tree.pptxbinary tree.pptx
binary tree.pptx
SANJUSANJEEVTOPPO
ย 

More from SANJUSANJEEVTOPPO (9)

masterpages 1.pptx
masterpages 1.pptxmasterpages 1.pptx
masterpages 1.pptx
ย 
ppt2.pptx
ppt2.pptxppt2.pptx
ppt2.pptx
ย 
thread os.pptx
thread os.pptxthread os.pptx
thread os.pptx
ย 
ppt1.pptx
ppt1.pptxppt1.pptx
ppt1.pptx
ย 
Entrepreneurship CS.pptx
Entrepreneurship CS.pptxEntrepreneurship CS.pptx
Entrepreneurship CS.pptx
ย 
sampling RM.pptx
sampling RM.pptxsampling RM.pptx
sampling RM.pptx
ย 
C language.pptx
C language.pptxC language.pptx
C language.pptx
ย 
binary tree.pptx
binary tree.pptxbinary tree.pptx
binary tree.pptx
ย 
stack ppt.pptx
stack ppt.pptxstack ppt.pptx
stack ppt.pptx
ย 

Recently uploaded

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
ย 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
ย 

Recently uploaded (20)

Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
ย 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
ย 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
ย 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
ย 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
ย 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
ย 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
ย 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
ย 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
ย 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
ย 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
ย 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
ย 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
ย 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
ย 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
ย 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
ย 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
ย 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
ย 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
ย 

template c++.pptx

  • 1. SESSION โ€“ (2022-23) A Seminar on โ€œTemplatesโ€ Oopโ€™s concept in c++ Guided by : Presented by : Md. Afroj Ansari Sanju Sanjeev Toppo (Ass. Professor of cs) Msc.cs II-semester Roll no : 09 Date : 18/05/2023
  • 2. โ€ข Template 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 TEMPLATES
  • 3. โ€ข Used in large programs โ€ข Code reusability โ€ข Time saving โ€ข Flexibility of program Purpose of Templates
  • 5. โ€ข A Class Template can represent various similar classes operating on different data types. Syntax: template < class T1, class T2,โ€ฆ> class classname { functions; }; Class Templates
  • 6. โ€ข 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. Template class
  • 7. โ€ข 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 โ€ฆโ€ฆโ€ฆ }; Class Templates with Multiple Parameters
  • 8. โ€ข 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 } Function Templates
  • 9. template < class T> void swap ( T &x, T &y) { T temp = x; x = y; y = temp; } Example
  • 10. Syntax: template < class T1, class T2,โ€ฆ.> returntype functionname(arguments of types T1,T2,..) { body of the function } Function Template With Multiple Parameters