SlideShare a Scribd company logo
1 of 14
OBJECT ORIENTED
PROGRAMMING
CONTENTS:
• Expectation Handling
• Functional template
• Member template
• Class template
• Specialization
EXPECTATION HANDLING
• What is expectation?
• Special condition that change normal flow of program execution.
• Provide a way for transferring control.
• C++ support language constructs.
EXPECTATION HANDLING
• Built upon three keywords.
• TRY
• CATCH
• Throw
• Catches an exception using a combination of the try and catch keywords.
• try/catch block might generate an expectation.
EXPECTATION HANDLING
• Example of a try and catch block combination.
EXPECTATION HANDLING
Writing expectation safe code
• Piece of code is said to be exception-safe, if run-time failures within the code will
not produce ill effects, such as memory leaks.
• Several levels of expectation safety.
• Failure transparency
• Commit or rollback semantics
• Basic exception safety
• Minimal exception safety
• No exception safety
WHY EXPECTATION HANDLING?
• Separation of Error Handling code from Normal Code
• Making code maintainable and readable.
• Functions/Methods can handle any exceptions they choose
• In C++, we use built in keyword “throw”.
• Grouping of Error Types
• Create hierarchy of exception objects.
TEMPLATE
• What is template?
• Use to define functions as well as classes.
• Use in larger code base for the purpose
of code reusability and flexibility.
• Concept of template used in two different ways
• Function Template
• Class Template
• Member template
FUNCTION TEMPLATE
• Function templates are special functions that can operate with generic types.
• Declaration of function template
• Work in a similar to a normal function
CLASS TEMPLATE
• Like function template, we can also create class template.
• Sometimes, need a class implementation that is same for all classes,
only the data types used are different.
• Create different class for each data type
OR
Create different variables within a single class.
• Declaration of class template
MEMBER TEMPLATE
• Term refer to both member function template and nested class template.
• Member function templates are template functions that are member of a
class.
• Member functions can be function templates in several contexts.
• All functions are generic but not referred to as MFT.
• If these MF take their own template arguments, they are considered to
member function templates.
• MFT of non or template classes are declared as
TEMPLATE SPECIALIZATION
• Template is a feature in C++
• Write code once and us it for any data types including user defined.
• Get a special behavior for a particular data type known as
Template Specialization.
TEMPLATE SPECIALIZATION
• How does template specialization work?
• Compiler creates a copy of that function/class.
• If specialized version is present, compiler first checks with specialized version
and then main template.
• The idea of template specialization is to override the default template
implementation to handle a particular type in a different way.
THANK YOU.

More Related Content

What's hot

Code reviews
Code reviewsCode reviews
Code reviewsRoger Xia
 
Api testing libraries using java script an overview
Api testing libraries using java script   an overviewApi testing libraries using java script   an overview
Api testing libraries using java script an overviewvodQA
 
Android course session 1 ( intoduction to java )
Android course session 1 ( intoduction to java )Android course session 1 ( intoduction to java )
Android course session 1 ( intoduction to java )Keroles M.Yakoub
 
Robot Framework Dos And Don'ts
Robot Framework Dos And Don'tsRobot Framework Dos And Don'ts
Robot Framework Dos And Don'tsPekka Klärck
 
Play with elm - Choucri fahed, Finstack - Lambadays
Play with elm - Choucri fahed, Finstack - LambadaysPlay with elm - Choucri fahed, Finstack - Lambadays
Play with elm - Choucri fahed, Finstack - LambadaysFinstack
 
Java and effective programming. Is it possible? - IAESTE Case Week 2016
Java and effective programming. Is it possible? - IAESTE Case Week 2016Java and effective programming. Is it possible? - IAESTE Case Week 2016
Java and effective programming. Is it possible? - IAESTE Case Week 2016Łukasz Koniecki
 
Creational abstract factory_design_pattern
Creational abstract factory_design_patternCreational abstract factory_design_pattern
Creational abstract factory_design_patternbhaskara k
 
Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins Udaya Kumar
 
Effective programming in Java - Kronospan Job Fair 2016
Effective programming in Java - Kronospan Job Fair 2016Effective programming in Java - Kronospan Job Fair 2016
Effective programming in Java - Kronospan Job Fair 2016Łukasz Koniecki
 
Autoframework design
Autoframework designAutoframework design
Autoframework designForge Events
 
TypeScript Modules
TypeScript ModulesTypeScript Modules
TypeScript ModulesNoam Kfir
 
Byte code manipulation and instrumentalization in Java
Byte code manipulation and instrumentalization in JavaByte code manipulation and instrumentalization in Java
Byte code manipulation and instrumentalization in JavaAlex Moskvin
 

What's hot (17)

Code reviews
Code reviewsCode reviews
Code reviews
 
Api testing libraries using java script an overview
Api testing libraries using java script   an overviewApi testing libraries using java script   an overview
Api testing libraries using java script an overview
 
Php traits
Php traitsPhp traits
Php traits
 
Lambdas
LambdasLambdas
Lambdas
 
Android course session 1 ( intoduction to java )
Android course session 1 ( intoduction to java )Android course session 1 ( intoduction to java )
Android course session 1 ( intoduction to java )
 
Swift
SwiftSwift
Swift
 
Robot Framework Dos And Don'ts
Robot Framework Dos And Don'tsRobot Framework Dos And Don'ts
Robot Framework Dos And Don'ts
 
Play with elm - Choucri fahed, Finstack - Lambadays
Play with elm - Choucri fahed, Finstack - LambadaysPlay with elm - Choucri fahed, Finstack - Lambadays
Play with elm - Choucri fahed, Finstack - Lambadays
 
Java and effective programming. Is it possible? - IAESTE Case Week 2016
Java and effective programming. Is it possible? - IAESTE Case Week 2016Java and effective programming. Is it possible? - IAESTE Case Week 2016
Java and effective programming. Is it possible? - IAESTE Case Week 2016
 
Flow control in Python
Flow control in PythonFlow control in Python
Flow control in Python
 
Introduction to Python Programming
Introduction to Python Programming Introduction to Python Programming
Introduction to Python Programming
 
Creational abstract factory_design_pattern
Creational abstract factory_design_patternCreational abstract factory_design_pattern
Creational abstract factory_design_pattern
 
Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins
 
Effective programming in Java - Kronospan Job Fair 2016
Effective programming in Java - Kronospan Job Fair 2016Effective programming in Java - Kronospan Job Fair 2016
Effective programming in Java - Kronospan Job Fair 2016
 
Autoframework design
Autoframework designAutoframework design
Autoframework design
 
TypeScript Modules
TypeScript ModulesTypeScript Modules
TypeScript Modules
 
Byte code manipulation and instrumentalization in Java
Byte code manipulation and instrumentalization in JavaByte code manipulation and instrumentalization in Java
Byte code manipulation and instrumentalization in Java
 

Similar to Object oriented programming

Programming language paradigms
Programming language paradigmsProgramming language paradigms
Programming language paradigmsAshok Raj
 
Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1Sachintha Gunasena
 
Building iOS App Project & Architecture
Building iOS App Project & ArchitectureBuilding iOS App Project & Architecture
Building iOS App Project & ArchitectureMassimo Oliviero
 
Ansible Best Practices - July 30
Ansible Best Practices - July 30Ansible Best Practices - July 30
Ansible Best Practices - July 30tylerturk
 
Templates and Exception Handling in C++
Templates and Exception Handling in C++Templates and Exception Handling in C++
Templates and Exception Handling in C++Nimrita Koul
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming WebStackAcademy
 
Learning from "Effective Scala"
Learning from "Effective Scala"Learning from "Effective Scala"
Learning from "Effective Scala"Kazuhiro Sera
 
java tutorial for beginners learning.ppt
java tutorial for beginners learning.pptjava tutorial for beginners learning.ppt
java tutorial for beginners learning.pptusha852
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesInductive Automation
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programmingJuggernaut Liu
 

Similar to Object oriented programming (20)

Design p atterns
Design p atternsDesign p atterns
Design p atterns
 
Programming language paradigms
Programming language paradigmsProgramming language paradigms
Programming language paradigms
 
Clean code
Clean codeClean code
Clean code
 
Eurosport's Kodakademi #2
Eurosport's Kodakademi #2Eurosport's Kodakademi #2
Eurosport's Kodakademi #2
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1
 
Building iOS App Project & Architecture
Building iOS App Project & ArchitectureBuilding iOS App Project & Architecture
Building iOS App Project & Architecture
 
Java annotations
Java annotationsJava annotations
Java annotations
 
Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
 
Ansible Best Practices - July 30
Ansible Best Practices - July 30Ansible Best Practices - July 30
Ansible Best Practices - July 30
 
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin KalapaćJavantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
 
Exception handling in .net
Exception handling in .netException handling in .net
Exception handling in .net
 
Templates and Exception Handling in C++
Templates and Exception Handling in C++Templates and Exception Handling in C++
Templates and Exception Handling in C++
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
 
Learning from "Effective Scala"
Learning from "Effective Scala"Learning from "Effective Scala"
Learning from "Effective Scala"
 
java tutorial for beginners learning.ppt
java tutorial for beginners learning.pptjava tutorial for beginners learning.ppt
java tutorial for beginners learning.ppt
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Exception handling in ASP .NET
Exception handling in ASP .NETException handling in ASP .NET
Exception handling in ASP .NET
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programming
 

More from Tayyab Hussain

Corona Virus Disease Covid-19 presentation
Corona Virus Disease Covid-19 presentation Corona Virus Disease Covid-19 presentation
Corona Virus Disease Covid-19 presentation Tayyab Hussain
 
Software requirement document
Software requirement documentSoftware requirement document
Software requirement documentTayyab Hussain
 
Library Management system
Library Management systemLibrary Management system
Library Management systemTayyab Hussain
 
Information Technology
Information TechnologyInformation Technology
Information TechnologyTayyab Hussain
 
Capacitor Presentation
Capacitor PresentationCapacitor Presentation
Capacitor PresentationTayyab Hussain
 

More from Tayyab Hussain (7)

Corona Virus Disease Covid-19 presentation
Corona Virus Disease Covid-19 presentation Corona Virus Disease Covid-19 presentation
Corona Virus Disease Covid-19 presentation
 
Social media
Social mediaSocial media
Social media
 
Software requirement document
Software requirement documentSoftware requirement document
Software requirement document
 
Deathnote
DeathnoteDeathnote
Deathnote
 
Library Management system
Library Management systemLibrary Management system
Library Management system
 
Information Technology
Information TechnologyInformation Technology
Information Technology
 
Capacitor Presentation
Capacitor PresentationCapacitor Presentation
Capacitor Presentation
 

Recently uploaded

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 

Recently uploaded (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 

Object oriented programming

  • 2. CONTENTS: • Expectation Handling • Functional template • Member template • Class template • Specialization
  • 3. EXPECTATION HANDLING • What is expectation? • Special condition that change normal flow of program execution. • Provide a way for transferring control. • C++ support language constructs.
  • 4. EXPECTATION HANDLING • Built upon three keywords. • TRY • CATCH • Throw • Catches an exception using a combination of the try and catch keywords. • try/catch block might generate an expectation.
  • 5. EXPECTATION HANDLING • Example of a try and catch block combination.
  • 6. EXPECTATION HANDLING Writing expectation safe code • Piece of code is said to be exception-safe, if run-time failures within the code will not produce ill effects, such as memory leaks. • Several levels of expectation safety. • Failure transparency • Commit or rollback semantics • Basic exception safety • Minimal exception safety • No exception safety
  • 7. WHY EXPECTATION HANDLING? • Separation of Error Handling code from Normal Code • Making code maintainable and readable. • Functions/Methods can handle any exceptions they choose • In C++, we use built in keyword “throw”. • Grouping of Error Types • Create hierarchy of exception objects.
  • 8. TEMPLATE • What is template? • Use to define functions as well as classes. • Use in larger code base for the purpose of code reusability and flexibility. • Concept of template used in two different ways • Function Template • Class Template • Member template
  • 9. FUNCTION TEMPLATE • Function templates are special functions that can operate with generic types. • Declaration of function template • Work in a similar to a normal function
  • 10. CLASS TEMPLATE • Like function template, we can also create class template. • Sometimes, need a class implementation that is same for all classes, only the data types used are different. • Create different class for each data type OR Create different variables within a single class. • Declaration of class template
  • 11. MEMBER TEMPLATE • Term refer to both member function template and nested class template. • Member function templates are template functions that are member of a class. • Member functions can be function templates in several contexts. • All functions are generic but not referred to as MFT. • If these MF take their own template arguments, they are considered to member function templates. • MFT of non or template classes are declared as
  • 12. TEMPLATE SPECIALIZATION • Template is a feature in C++ • Write code once and us it for any data types including user defined. • Get a special behavior for a particular data type known as Template Specialization.
  • 13. TEMPLATE SPECIALIZATION • How does template specialization work? • Compiler creates a copy of that function/class. • If specialized version is present, compiler first checks with specialized version and then main template. • The idea of template specialization is to override the default template implementation to handle a particular type in a different way.

Editor's Notes

  1. 1. problem that arises during the execution of a program. such as in coding we add a such a function in which we are dividing numerator by zero. 2. Exception handling is a construct designed to handle the occurrence of exceptions, that is special conditions that changes the normal flow of program execution. 4. one cannot always assume that application/task will run or be completed correctly (exit with the result it was intended to). If this is not the case then ++ supports the use of language constructs to separate error handling and reporting code from ordinary code,
  2. 1. C++ exception handling is built upon three keywords: try, catch, and throw. throw − A program throws an exception when a problem shows up. This is done using a throw keyword. catch − A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception. try − A try block identifies a block of code for which particular exceptions will be activated. It's followed by one or more catch blocks. 2. a method catches an exception using a combination of the try and catch keywords. 3. Code within a try/catch block is referred to as protected code, and the syntax for using try/catch as follows −
  3. also known as the no throw guarantee: Operations are guaranteed to succeed and satisfy all requirements even in presence of exceptional situations. also known as strong exception safety or no-change guarantee: Operations can fail, but failed operations are guaranteed to have no side effects so all data retain original values. Partial execution of failed operations can cause side effects. also known as no-leak guarantee: Partial execution of failed operations may store invalid data but will not cause a crash. No guarantees are made. (Worst level of exception safety).
  4. In traditional error handling codes, there are always if else conditions to handle errors. This makes the code less readable and maintainable. With try catch blocks, the code for error handling becomes separate from the normal flow. A function can throw many exceptions, but may choose to handle some of them. The other exceptions which are thrown, but not caught can be handled by caller. If the caller chooses not to catch them, then the exceptions are handled by caller of the caller. both basic types and objects can be thrown as exception. We can create a hierarchy of exception objects, group exceptions in namespaces or classes, categorize them according to types.
  5. Templates are the foundation of generic programming, which involves writing code in a way that is independent of any particular type.
  6. 2. When we write any template based function or class, compiler creates a copy of that function/class whenever compiler sees that being used for a new data type or new set of data types(in case of multiple template arguments).