Answer the following statements true (T) or false (F)

1. Templates can make available to the programmer the generality of algorithms that implementation with specific types conceals.
2. With regard to programming usage, consistency in coding is more important than optimality.
3. To instantiate and call, a template function requires special syntax.
4. The template prefix can be written template or template with the same results.
5. Templates provide an overloading of the function for every possible type that is consistent with the use in the template.

1. True
In many functions, the algorithm that is implemented is more general than the implementation. Templates provide, in effect, an overloading of the function for every possible type that is consistent with the use in the template. For example, if you assign template parameter objects, this must make sense for the type.
2. True.
If one is inconsistent with many details in coding, the reader will make more errors than would happen otherwise.
3. False.
If the function template is available in the file, it is only necessary to write the function name with arguments, that is, to act as if the needed function definition is already present. The compiler will figure out the types and generate the instance of the function template.
4. True
The C++ Standard provides for use of either class or typename in here, but the text, recognizing common usage, has standardized on the use of the keyword class. Nevertheless, you may see this in code you read, so you should be able to recognize it.
5. False
The compiler does not provide every possible overloading. Nevertheless, the compiler does behave as though overloadings for every possible type were present.

Computer Science & Information Technology

You might also like to view...

The process of addingdata from an Excel spreadsheet to an existing Access table that is closed

a. Exporting b. Expending c. Appending

Computer Science & Information Technology

Which of the following is NOT true about creating a lookup field by using the Lookup Wizard?

A) It simplifies the process. B) It automatically populates the associated field properties. C) It creates the needed table relationships. D) It automatically populates the data for the field.

Computer Science & Information Technology