1/24
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
These are used to signal errors or unexpected events that occur while a program is running
Exceptions
The ________ starts with the keyword “try”, and is followed by a block of code executing any statements that might cause an exception to be thrown.
try block
When an error occurs, an exception is _______.
thrown
An exception thrown from outside a try block _______.
will cause the program to abort excecution
If an exception is thrown by a member function of a class object, then the class ________ is called.
catcher/ handler
In a function template, the programmer substitutes _______ for _______.
parameters, data types
A(n) __________ is used in a function template to specify a generic data type
type parameter
The beginning of a function template is marked by a _________.
template prefix
class templates allow you to create one general version of a class without having to _______.
duplicate code to handle multiple data types
In the following statement:
template <class T>
what does the word “class” indicate?
“class” is a keyword that is used to precede the type parameter T.
A(n) _________ is a value or an object that signals an error.
exception
To handle an exception that has been thrown, a program must have a(n) ________.
try/ catch construct
The try block is immediately followed by one or more _______.
catch blocks
Catch blocks serve as ______.
exception handlers
This is a “generic” function that can work with any data type
function template
All type parameters defined in a function template must appear at least once in the ______.
function's parameter list
A function template’s prefix contains _______ enclosed in angled brackets
one or more generic data types
An actual instance of the function is created in memory when the complier encounters ______.
a call to the template function
A function template prefix is placed before the function header. A class template prefix is placed ________.
before the class declaration
The most important data structure in the STL are ______ and _______.
containers, iterators
T/F: The try/ catch/ throw construct is able to handle only one type of exception in a try block
False, it can handle multiple types.
T/F: There is no difference between declaring an object of an ordinary class and an object of a template class
False, template classes allow for parameterized types and can be instantiated with different data types.
T/F: The line containing a “throw” statement is known as the throw point.
True, this is where an exception is raised.
T/F: Function templates allow you to write a single function definition that works with many diffrent data types
True, they enable code reuse and flexibility by allowing the same function to operate on varying types without rewriting code.
T/F: Using a function template requires less code than overloading a function
True, function templates provide a more concise way to handle multiple data types without repeating the same logic.