C++ Exception Handling with Examples (Basic to Advanced)

Learn how to implement Exception Handling in C++, covering every basic topic in detail with the help of C++ Examples.
3.3 (4 ratings) Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
560 students enrolled
$20
Take This Course
  • Lectures 16
  • Contents Video: 2 hours
  • Skill Level All Levels
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

Learn and practice real-world skills and achieve your goals.

About This Course

Published 5/2015 English

Course Description

Want to learn the most typical and important topic in any programming language. In this course you will learn Exception Handling in C++ covering all the basic to advanced topics with the help of great examples along the way.

I will be using Dev C++ as a compiler but you can use any compiler of your choice. Before starting the course you should have at least basic understanding of C++ syntax - operators, functions, control structure.

The course contains 5 section having total of 11 lectures - 2 hours of video content. Apart from that there are 9 C++ files included in the "Downloadable Resource" section for better understanding of its concepts. Also various MCQ's / Quizzes for better understanding of your concepts.

Here's a list of topics covered in the course -

  1. Why there was a need for exception handling.
  2. Basics of Exception Handling.
  3. How Exception handling works / mechanism.
  4. Use of try, catch and throw.
  5. Function that generates exception.
  6. Multiple catch statements.
  7. How to Catch all the exceptions using (...)
  8. Nested exception handling
  9. Restricting / Specifying throw restriction
  10. Re throwing an Exception

And much more along the way...

This topic is highly recommended on the perspective of Interviews for companies or Examination.

What are the requirements?

  • You should already be familiar with the basic syntax of C++ - functions, control structure, operators and variables.

What am I going to get from this course?

  • Understand why Exception Handling was required
  • 9 downloadable C++ examples covered in the course
  • How Exception handling works / mechanism.
  • Use try, catch and throw and implement your own programs.
  • Make your own program covering all topics from Basics to Advanced

What is the target audience?

  • The course is suitable for beginners in C++ programming language - functions, operators, variables, control structure.
  • Please do not take the course if you have no prior experience in any programming language.

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.

Curriculum

Section 1: Introduction
03:41

A Brief Introduction of the course, about its contents, Prerequisites of the course and knowing whether the course is right for you or not.

07:00

In this lecture we will be installing Dev C++ for Windows and Code Blocks for Linux and Mac Users. Off course you can use any other compiler of your own. I will be using Dev C++ throughout the course.

Download Dev C++ here - http://www.bloodshed.net/dev/devcpp.html

Download Code Blocks for Mac and Linux Users - http://www.codeblocks.org/downloads/26

Let me know if any of the link is not working.

04:41

In this lecture you will learn "why there is a need for Exception Handling." You can download the C++ file made in the lecture from the "Downloadable Resources" section.

Well we need to handle certain exceptions, For example - 10/0 is infinite or not defined. But computer doesn't know this and it generates an error as a result we are not able to run our programs. So we need certain mechanism called "Exception Handling" to handle such thing. But more on that later in the next lecture.

How it works?
1 question
Section 2: Basic Exception Handling
01:01

A brief description of what's inside Section 2 of this course. What topics you should emphasize on and what you will be able to implement at the end of this section.

15:30

In this lecture, you will learn understand the concept of Exception Handling, i.e, how it works. You will also know about there words which you should get yourself familiar with, i.e., try, catch and throw.

Try is used for handling the exception. Inside try block we have a throw statement which literally throws something. Finally we have catch block which accepts as a parameter the same data type which we have throw.

You can download the C++ file made in the lecture from the "Downloadable Resources" section.

09:06

In this lecture we will cover another example for Exception Handling. You will again use a try block that throws and integer as a result a catch block that receives an integer (with a formal parameter). Please note - catch Block will always immediately follow try block, no matter what.

You can download the C++ file made in the lecture from the "Downloadable Resources" section.

Basics
1 question
Section 3: Function Generating Exception
00:47

A brief description of what's inside Section 3 of this course. What topics you should emphasize on and what you will be able to implement at the end of this section.

06:24

In this lecture you will learn how to create a function that generates an Exception. First we will create a try block, and inside it we will call that function that generates an exception. Inside the function definition we will have a throw statement which will throw an exception. A throw block will be there(obviously - everytime you write a try block, make a catch block immediately) which will catch the exception.

You can download the C++ file made in the lecture from the "Downloadable Resources" section.

01:36

An extra lecture for throw keyword. How we can alter or write it in different ways.

Basics of Function generating exceptions
1 question
Section 4: Multiple Catch Statements
00:56

A brief description of what's inside Section 4 of this course. What topics you should emphasize on and what you will be able to implement at the end of this section.

09:06

In this lecture you will learn the concept of "Multiple catch" statements. It is used so that we can catch different types of data types depending on what data type was thrown from the throw statement. For catching any data type whether it is float, integer, character or double(any) we use (...) inside the catch statement as catch(...) which signifies that any it can catch any type of data thrown.

You can download the C++ file made in the lecture from the "Downloadable Resources" section.

08:40

Another example for "Multiple catch statements" to help you better understand this concept.

You can download the C++ file made in the lecture from the "Downloadable Resources" section.

Basics of Multiple catch
1 question
Section 5: Advanced Section
02:04

A brief description of what's inside Section 5 of this course. What topics you should emphasize on and what you will be able to implement at the end of this section as well as at the end of the course.

07:50

Just like we have nested "if statements", we can also create nested try blocks, i.e., another try block inside a try block.

You can download the C++ file made in the lecture from the "Downloadable Resources" section.

Basics
1 question
15:17

In this lecture you will learn how can we restrict our compiler to throw only certain data types. Now if you throw any other data type other than that you specified your compiler will stop working, since you now have a function that has restricted to throw only certain data types that you specified.

You can download the C++ file made in the lecture from the "Downloadable Resources" section.

16:35

Up till now we were throwing an exception either inside a try block or inside a function that was called from try block. Now we will learn how to put a throw statement inside a catch block by keyword throw; to rethrow the same exception that was being caught by that catch block.

You can download the C++ file made in the lecture from the "Downloadable Resources" section.

Basics of rethrow
1 question

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Anuj Kumar, Programmer

Programming is Epic and also my passion. Hello everyone, I am Anuj kumar. I am currently pursuing Computer Science Engineering. I have been programming from the past 3 years in various programming languages such as C, C++, Java. I also have a keen interest in Web Development and Android Development. Technology advances daily, there is a lot that I still need to learn.

Ready to start learning?
Take This Course