COMS 250: Exam 3: Exceptions and Templates

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/24

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

25 Terms

1
New cards

These are used to signal errors or unexpected events that occur while a program is running

Exceptions

2
New cards

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

3
New cards

When an error occurs, an exception is _______.

thrown

4
New cards

An exception thrown from outside a try block _______.

will cause the program to abort excecution

5
New cards

If an exception is thrown by a member function of a class object, then the class ________ is called.

catcher/ handler

6
New cards

In a function template, the programmer substitutes _______ for _______.

parameters, data types

7
New cards

A(n) __________ is used in a function template to specify a generic data type

type parameter

8
New cards

The beginning of a function template is marked by a _________.

template prefix

9
New cards

class templates allow you to create one general version of a class without having to _______.

duplicate code to handle multiple data types

10
New cards

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.

11
New cards

A(n) _________ is a value or an object that signals an error.

exception

12
New cards

To handle an exception that has been thrown, a program must have a(n) ________.

try/ catch construct

13
New cards

The try block is immediately followed by one or more _______.

catch blocks

14
New cards

Catch blocks serve as ______.

exception handlers

15
New cards

This is a “generic” function that can work with any data type

function template

16
New cards

All type parameters defined in a function template must appear at least once in the ______.

function's parameter list

17
New cards

A function template’s prefix contains _______ enclosed in angled brackets

one or more generic data types

18
New cards

An actual instance of the function is created in memory when the complier encounters ______.

a call to the template function

19
New cards

A function template prefix is placed before the function header. A class template prefix is placed ________.

before the class declaration

20
New cards

The most important data structure in the STL are ______ and _______.

containers, iterators

21
New cards

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.

22
New cards

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.

23
New cards

T/F: The line containing a “throw” statement is known as the throw point.

True, this is where an exception is raised.

24
New cards

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.

25
New cards

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.