Chapter 10 COP 3300
A class template can be derived from a non-template class.
True
A non-template class can be derived from a class template instantiation.
True
In implementing class template member functions, the functions are themselves templates.
True
It is possible to have more than one type parameter in a template definition.
True
Suppose the swapValues template is instantiated as follows: int x = 2, y =3; swapValue(x, y); // use x and y and double d= 3.0, f=4.5; swap(d, f); // use x and y Then the compiler generates code for two copies of the swapValues template.
True
Templates can make available to the programmer the generality of algorithms that implementation with specific types conceals.
True
How many type parameters may a function template have?
as many as are needed
There may be more than one correct answer. You must give all correct answers for full credit. Templates may be used to make available a very large collection of.... Group of answer choices
functions classes
The code for a template function is generated when
the function call is encountered in the C++ program during compilation
A class template cannot be derived from a class template.
False
In the implementation of a class template function, the class name before the scope resolution operator is just the class name, with no additional syntax.
False
In the template prefix, template <class T> the keyword class means that the type parameter T must be of class type.
False
In the template prefix, template<class T> the identifier T is called a value parameter.
False
In writing a class template, the function declarations within the class require special placement.
False
It is preferable to separate implementation and specification in software. Hence, it is preferable to place a template class definition in a "header" file, the template implementation of the member functions in an implementation file. The implementation should be compiled separately and linked to the application.
False
Suppose the swapValues template is instantiated as follows: int x = 2, y =3; swapValues(x, y); // use x and y x = 4; y =5; swapValues(x, y); // use x and y The compiler generates code for two copies of the swapValues template. Group of answer choices
False
Templates allow only parameterized types for class templates
False
Templates allow only parameterized types for functions.
False
Templates provide an overloading of the function for every possible type that is consistent with the use in the template.
False
The template prefix can be written template <typename identifier> or template <class identifier> with the same results.
False
To instantiate and call, a template function requires special syntax.
False
In the template prefix, template <class T>, what kinds of variables is the parameter T?
T can be any type, whether built into C++ or programmer defined, but subject to restrictions. Explain what these are.