1/22
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
an exception
undesriable or abnormal event that occurs during program execution
run time error(exeception)
an error that occurs during run time when the program encounters something that cannot run
exception handling
code that runs when an exception occurs
purpose of exception handling
code that runs when an exception occurs
try block
contains code that may produce an exception
throw
signals that an error has occured
catch block
handles the exception
type matching rule
the catch block handles only the type of the exception the code is designed for
no exception behavior
of no exception thrown, all catch blocks are skipped
exception thrown behavior
the try block ends and remaining statements are skipped
multiple catch blocks
only one matching catch block executes
catch all handler(…)
catches any type of exception and should be placed last
order of catch blocks
must go from more specific to less specific
assert
stops the program immediately if a condition is false
throwing an exception
we say that a program throws an exception
user defined exception
a class created by the programmer to handle specific errors
template
allows writing one function or class that works with different data types
function template
a function that can work with any data type using a template parameter
template syntax
template <class T>
template parameter(T)
a placeholder for a data type
generic programming
writing code that works for multiple data types
template function use
the compiler replaces T with the actual data type when the function is called
example idea
instead of writing multiple max functions, use one template function