← Quiz: Operators and Templates: all 10 questions
Quiz: Operators and Templates · Question 9 of 10
When does the compiler generate code from a function template?
When does the compiler generate code from a function template?
- A.When the template is defined, for every type
- B.When the template is used with a particular type (instantiation)
- C.At run time, when the function is first called
- D.Never; templates are interpreted
Answer & explanation
Correct answer: When the template is used with a particular type (instantiation)
Each distinct type used produces its own compiled version of the function.
Can you get the rest right without peeking?
Take the timed Quiz: Operators and Templates quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →