Answer the following questions true (T) or false (F)
1. 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.
2. Templates allow only parameterized types for class templates
1. False
Explanation: Most C++ compilers require the template class definitions and member function implementations to be in the same file with the application for compilation. There are compiler dependent #pragma commands for some compilers that more or less achieve the result mentioned in the question, but we have found them to be arcane and difficult to use.
It is possible to explicitly instantiate your templates for every use you have and place these in a separate file. With appropriate #pragma commands, this can be separately compiled and linked to your application. There is an issue of code bloat from compilers generating instantiations in every file where a template is instantiated. This method can prevent that problem.
2. False
Explanation: The template facility provides for both parameterized types in functions and in classes.
You might also like to view...
______ is information before it is encrypted.
Fill in the blank(s) with the appropriate word(s).
Draw a use case diagram for World’s Trend Catalog Division.
What will be an ideal response?
Panels are _________________________ when they display their contents.
Fill in the blank(s) with the appropriate word(s).
If you have generated the IP address 165.100.18.44/18 by using CIDR, what is the number of bits used for the host identifier?
A. 14 B. 18 C. 44 D. 100