[amp_mcq option1=”the generic class name” option2=”the keyword template” option3=”the keyword class” option4=”the template definition” correct=”option1″]
The correct answer is: A. the generic class name
A class template is a class that can be instantiated with different types. The type to be used in an instantiation of a class template follows the generic class name. For example, the following class template can be instantiated with any type T:
c++
template <typename T>
class MyClass {
public:
T data;
};
The following code instantiates MyClass with the type int:
c++
MyClass<int> myIntClass;
The variable myIntClass is of type MyClass, which means that it has a data member of type int.
The other options are incorrect because:
- B. the keyword template is used to introduce a class template.
- C. the keyword class is used to introduce a class.
- D. the template definition is the body of the class template.