O'Reilly logo

Sams Teach Yourself C++ in 24 Hours, Third Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required