Main Page

Previous Page
Next Page

[Page 766]

Self-Review Exercises


State which of the following statements are true and which are false. If a statement is false, explain why.

  1. 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.

  2. Keywords typename and class as used with a template type parameter specifically mean "any user-defined class type."

  3. A function template can be overloaded by another function template with the same function name.

  4. Template parameter names among template definitions must be unique.

  5. Each member-function definition outside a class template must begin with a template header.

  6. A friend function of a class template must be a function-template specialization.

  7. If several class-template specializations are generated from a single class template with a single static data member, each of the class-template specializations shares a single copy of the class template's static data member.


Fill in the blanks in each of the following:

  1. 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 __________.

  2. All function-template definitions begin with the keyword __________, followed by a list of template parameters to the function template enclosed in __________.

  3. The related functions generated from a function template all have the same name, so the compiler uses __________ resolution to invoke the proper function.

  4. Class templates also are called __________types.

  5. The __________ operator is used with a class-template name to tie each member-function definition to the class template's scope.

  6. As with static data members of nontemplate classes, static data members of classtemplate specializations must also be defined and, if necessary, initialized at __________ scope.

Previous Page
Next Page