Q&A

Q1:Why use templates when macros will do?
A1: Templates are type-safe and built into the language.
Q2:What is the difference between the parameterized type of a template function and the parameters to a normal function?
A2: A regular function (non-template) takes parameters on which it may take action. A template function allows you to parameterize the type of a particular parameter to the function.
Q3:When do you use templates and when do you use inheritance?
A3: Use templates when all the behavior or virtually all the behavior is unchanged, but the type of the item on which your class acts is different. If you find yourself copying a class and changing only the type of one or more of its members, it might be time to consider using a template.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.21.190