Chapter 1, Introduction to Templates
Question 1
Why do we need templates? What advantages do they provide?
Answer
There are several benefits to using templates: they help us avoid writing repetitive code, they foster the creation of generic libraries, and they can help us write less and better code.
Question 2
How do you call a function that is a template? What about a class that is a template?
Answer
A function that is a template is called a function template. Similarly, a class that is a template is called a class template.
Question 3
How many kinds of template parameters exist and what are they?
Answer
There are three kinds of template parameters: type template parameters, non-type template parameters, and template template parameters.
Question 4
What is partial specialization? What about full specialization?
Answer
Specialization is the technique of providing an alternative implementation for a template, called the primary template...