What is the proper place for the default value of a parameter ? Just in function definition, or declaration, or both places? Qt code has plenty of methods using this approach i.e. QDialog::QDialog(QWidget * parent = 0, Qt::WindowFlags f = 0) so what if you're defining a new method and need a similar behavior?
The answer is placing the default value in the method declaration (usually in a header file, .h)
The rationale is backed by an example from "Effective C++" by Scott Meyers, p. 132-134.) and it's very well explained here.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment