Exam 11: Using Templates

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Where in your program can you place function templates? Do any restrictions apply?

Free
(Essay)
4.9/5
(36)
Correct Answer:
Verified

You can place function templates at the start of a program file, in the global area above the main() function.Alternatively, you can place them in a separate file, and include that file in your program with an #include statement. In either case, the definition of the class template (the statement that contains the word template and the angle brackets holding the class name) and the function template itself must reside in the same source file.When you create a function template, you can't place the template definition and the function code in separate files because the function can't be compiled into object format without knowing the types, and the function won't "know" that it needs to recognize the types without the template definition.,

What happens when you call a function template?

Free
(Essay)
4.8/5
(38)
Correct Answer:
Verified

When you call a function template, the compiler determines the type of the actual argument passed to the function. The compiler substitutes the argument type for the generic type in the function template, creating a generated function that uses the appropriate type. The designation of the parameterized type is implicit; that is, it is determined not by naming the type, but by the compiler's ability to determine the argument type.The compiler generates code for as many different functions as it needs, depending on the function calls that are made.,

FIFO stands for ____________________.

Free
(Essay)
4.8/5
(45)
Correct Answer:
Verified

first in first out,first in, first out

When you create a(n) ____, you create a list of same-type objects at adjacent memory locations.

(Multiple Choice)
4.9/5
(34)

The terms template function and ____ are often used interchangeably.

(Multiple Choice)
4.9/5
(40)
Match each term with the correct statement below.
Premises:
data structure in which elements are removed in LIFO order
Responses:
queue
function template
stack
Correct Answer:
Verified
Premises:
Responses:
data structure in which elements are removed in LIFO order
queue
(Matching)
4.8/5
(31)
Match each term with the correct statement below.
Premises:
is generated by a function template
Responses:
stack
template class
generic parameter
Correct Answer:
Verified
Premises:
Responses:
is generated by a function template
stack
(Matching)
4.9/5
(30)

The function call ____ specifies that someFunction 's parameterized type (for example, T ) will be char , no matter what type someArgument is.

(Multiple Choice)
4.8/5
(40)

Function templates ____ support multiple parameters.

(Multiple Choice)
4.9/5
(38)

At a minimum, what components should a linked list element have?

(Essay)
4.9/5
(34)

When is explicitly specifying a type for the parameterized type useful?

(Essay)
4.7/5
(44)

A(n) ____ is one that can stand for any number of C++ types.

(Multiple Choice)
4.9/5
(46)

The subscript for any array can hold a value of 0 through ____.

(Multiple Choice)
4.8/5
(34)

A(n) ____ is a template class that has been written to perform common class tasks.

(Multiple Choice)
4.9/5
(41)
Match each term with the correct statement below.
Premises:
is generated by a class template
Responses:
function template
template function
family of functions
Correct Answer:
Verified
Premises:
Responses:
is generated by a class template
function template
(Matching)
4.9/5
(30)

To create a function template that employs multiple generic types, you simply use a(n) ____ for each type.

(Multiple Choice)
4.7/5
(47)
Match each term with the correct statement below.
Premises:
can stand for any number of C++ types
Responses:
template class
family of functions
stack
Correct Answer:
Verified
Premises:
Responses:
can stand for any number of C++ types
template class
(Matching)
4.8/5
(42)

Function templates cannot use variables of multiple types.

(True/False)
4.8/5
(36)

You can overload function templates only when each version of the function takes a different parameter list.

(True/False)
4.9/5
(45)

The purpose of container classes is to manage groups of other classes.

(True/False)
4.9/5
(32)
Showing 1 - 20 of 54
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)