Vous êtes sur la page 1sur 2

Sabloni

a) The template parameters of a function-template definition are used to specify the types
of the arguments to the function, to specify the return type of the function and to declare
variables within the function.
True;
b) Keywords typename and class as used with a template type parameter specifically mean
any user-defined class type.

False(Keywords typename and class in this context also allow for a type parameter
of a fundamental type.)
c) A function template can be overloaded by another function template with the same
function name.
True;
d) Template parameter names among template definitions must be unique.
False. Template parameter names among function templates
need not be unique.
e) Each member-function definition outside a class template must begin with a template
header.

e) True.

a) Templates enable us to specify, with a single code segment, an entire range of related
functions called function-template specializations, or an entire range of related classes called
class-template specializations.
b) All function-template definitions begin with the keyword template , followed by a list
of template parameters to the function template enclosed in angle
brackets (< and >) .
c) The related functions generated from a function template all have the same name, so
the compiler uses overload resolution to invoke the proper function.
d) Class templates also are called parameterized types.
e) The scope resolution operator is used with a class-template name to tie each memberfunction
definition to the class templates scope

Nasljedjivanje
a) Treating a base-class object as a(n) derived class object can cause errors.
b) Polymorphism helps eliminate switch logic.
c) If a class contains at least one pure virtual function, its a(n) abstract class.
d) Classes from which objects can be instantiated are called concrete classes.
e) Operator dynamic_cast can be used to downcast base-class pointers safely.
g) Polymorphism involves using a base-class pointer or reference to invoke virtual functions
on base-class and derived-class objects.
h) Overridable functions are declared using keyword virtual.
i) Casting a base-class pointer to a derived-class pointer is called downcasting.
a) All virtual functions in an abstract base class must be declared as pure virtual functions.
False. An abstract base class can include virtual functions with implementations.
b) Referring to a derived-class object with a base-class handle is dangerous.
False.
Referring to a base-class object with a derived-class handle is dangerous.
c) A class is made abstract by declaring that class virtual.
False. Classes are never
declared virtual. Rather, a class is made abstract by including at least one pure virtual function
in
the class.
d) If a base class declares a pure virtual function, a derived class must implement that

function to become a concrete class.


True
d) Polymorphic programming can eliminate the need for
True;

switch

logic.

Vous aimerez peut-être aussi