ACtE03 · Chapter 3Programming & Applications🏛️ Past Licensure QuestionID: 63599a32
In C++ generic programming, what does the construct template <typename T> class MyClass define?
In C++ generic programming, what does the construct template <typename T> class MyClass define?
Multiple Choice Options
- A✓ Correct Option
A Class Template (Generic class)
- B
A Concrete final class
- C
A Pure abstract interface without implementations
- D
A Function macro definition
Detailed Technical Solution & Explanation
template <typename T> class MyClass defines a class template (generic class), which serves as a blueprint from which the compiler instantiates concrete classes when specialized with specific type arguments (e.g., MyClass<int>).
Option Analysis:
•
Option A (A Class Template (Generic class)): Correct. Allows parameterizing class definitions with arbitrary types.
•
Option B (A Concrete final class): Concrete classes have fixed types; template classes are generic parameterizations.
•
Option C (A Pure abstract interface without imp...): Defined via pure virtual functions (
= 0), not merely templating.•
Option D (A Function macro definition): Macros are processed by the preprocessor, whereas templates are language-level type constructors.
Reference: Demo2 · Set 2NEC Licensure Syllabus