ACtE03 · Chapter 3Programming & Applications🏛️ Past Licensure QuestionID: 576b8eb0
In C++, the template mechanism can be fundamentally applied to which two main program constructs?
In C++, the template mechanism can be fundamentally applied to which two main program constructs?
Multiple Choice Options
- A
Namespaces and Macros
- B✓ Correct Option
Function templates and Class templates
- C
Variables and Enumerations only
- D
Pointers and Arrays only
Detailed Technical Solution & Explanation
In classic C++, generic programming via templates is provided in two primary forms: Function Templates (generating type-independent functions) and Class Templates (generating type-independent classes and containers like std::vector<T>).
Option Analysis:
•
Option A (Namespaces and Macros): Namespaces and preprocessor macros cannot be templated.
•
Option B (Function templates and Class templates): Correct. The two core template paradigms in C++.
•
Option C (Variables and Enumerations only): Variable templates were added in C++14, but foundational template design is functions and classes.
•
Option D (Pointers and Arrays only): Pointers/arrays are types, not template constructs.
Reference: Mock Test 05NEC Licensure Syllabus