Group 1 Exercises

Please try individually to fill in the blanks and answer the True or False in the questions of the second exercise. You should also be able to justify your answer.

Exercise 1:

State which of the following are true and which are false. If false, explain why.

a) Templates enable us to specify a range of related classes called function-template specializations.

b) The names of template parameters must be unique inside a template definition.

c) It is not possible to use nontype parameters in a function template declaration.

d) If both the template and non-template versions of a function match a call, the non template version will be used.


Exercise 2:

Fill in the blanks in each of the following:

a) Templates enable us to specify, with a single code segment, an entire range of related functions called _______ , or an entire range of related classes called _______ .

b) When programming is done with templates, it is called _______    .

c) By enabling a variety of type-specific class template specializations to be instantiated from a single class template, class templates encourage _______   .

e) The _______   operator is used with a class-template name to tie each member-function definition to the class template’s scope.

Exercises have been taken from:

Deitel, Paul. C++ How to Program (Early Objects Version), Global Edition, 10th Edition. Pearson (Intl), 20170831.

Last modified: Tuesday, 11 December 2018, 6:24 AM