Q&A

Q1:Why would you ever use default values when you can overload a function?
A1: It is easier to maintain one function than two, and often easier to understand a function with default parameters than to study the bodies of two functions. Furthermore, updating one of the functions and neglecting to update the second is a common source of bugs.
Q2:Given the problems with overloaded functions, why not always use default values instead?
A2: Overloaded functions supply capabilities not available with default variables, such as varying the list of parameters by type rather than just by number.
Q3:When writing a class constructor, how do you decide what to put in the initialization and what to put in the body of the constructor?
A3: A simple rule of ...

Get Sams Teach Yourself C++ in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.