TITLE: Where to put default argument values PROBLEM: mharriso@digi.lonestar.org (Mark Harrison) When a member function has an initialized parameter, should the initialization go in the class declaration (in the header file) or in the function declaration? ... file X.h class X { void f(int n = 0); <------- here? }; file X.c X::f(int n = 0) <------- or here? (It's an error to do it twice) { // ... } RESPONSE: gs4t@virginia.edu (Gnanasekaran Swaminathan), 16 Jan 93 It depends on how you want to use it. Say for example, if you want all the users of class X to use the default value, then give the default value int the function declaration in class X. #include X a; a.f (); // ok. If on the other hand, you want the users to specify the value and only you, the class designer, want to use the default value, then give the default value in the function definition (in X.c) and write all other functions that will be making a call to the function and use the default value after the function definition. #include X a; a.f (); // error. no function X::f (). // X.cc void X::f (int n=0) {...} void X::g () { f (); // ok. use the default value }