Discussion
In C++ templates, which statement is TRUE ?
Answer: C
The true statement is that templates generate code during compilation.
A C++ template is a blueprint. When it is used with particular types, for example max<int> or vector<string>, the compiler instantiates it, generating a separate concrete function or class for those types at compile time. This is why templates give compile-time (static) polymorphism with no run-time cost.
Run-time polymorphism comes from virtual functions, not templates, so option A is false. Function templates can be overloaded, with each other and with ordinary functions. And templates may take several type parameters, as std::map<Key, Value> shows.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development