15 real Templates and Generics questions from the C++ bank, as asked in Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd — free to start.
1. What is Function template?
Junior
A.a parameterized blueprint from which the compiler generates concrete functions by deducing or supplying type arguments
B.an alternative definition supplied for a specific set of template arguments, overriding the primary template for those types
C.the rule that an invalid substitution of template arguments removes a candidate from overload resolution rather than causing a hard error
D.a template accepting an arbitrary number of arguments via a parameter pack that can be expanded recursively or with fold expressions
A.Function template — a parameterized blueprint from which the compiler generates concrete functions by deducing or supplying type arguments
B.Function template — the rule that an invalid substitution of template arguments removes a candidate from overload resolution rather than causing a hard error
C.Function template — a named compile-time predicate on template arguments that constrains which types may instantiate a template and improves error messages
D.Function template — an alternative definition supplied for a specific set of template arguments, overriding the primary template for those types
A.Template specialization — a named compile-time predicate on template arguments that constrains which types may instantiate a template and improves error messages
B.Template specialization — a parameterized blueprint from which the compiler generates concrete functions by deducing or supplying type arguments
C.Template specialization — an alternative definition supplied for a specific set of template arguments, overriding the primary template for those types
D.Template specialization — a template accepting an arbitrary number of arguments via a parameter pack that can be expanded recursively or with fold expressions
8. Which term means: "the rule that an invalid substitution of template arguments removes a candidate from overload resolution rather than causing a hard error"?
11. Which term means: "a named compile-time predicate on template arguments that constrains which types may instantiate a template and improves error messages"?
A.Concept (C++20) — a parameterized blueprint from which the compiler generates concrete functions by deducing or supplying type arguments
B.Concept (C++20) — a named compile-time predicate on template arguments that constrains which types may instantiate a template and improves error messages
C.Concept (C++20) — a template accepting an arbitrary number of arguments via a parameter pack that can be expanded recursively or with fold expressions
D.Concept (C++20) — an alternative definition supplied for a specific set of template arguments, overriding the primary template for those types
14. Which term means: "a template accepting an arbitrary number of arguments via a parameter pack that can be expanded recursively or with fold expressions"?
A.Variadic template — a parameterized blueprint from which the compiler generates concrete functions by deducing or supplying type arguments
B.Variadic template — a template accepting an arbitrary number of arguments via a parameter pack that can be expanded recursively or with fold expressions
C.Variadic template — a named compile-time predicate on template arguments that constrains which types may instantiate a template and improves error messages
D.Variadic template — an alternative definition supplied for a specific set of template arguments, overriding the primary template for those types
Answers, AI explanations, and a scored voice mock interview
Sign up free to check your answers with explanations, ask the AI tutor anything on any question, and take one full AI mock interview — scored like a real panel.