TITLE: default argument values and overloading (Newsgroups: comp.std.c++) PROBLEM: ??? I have a class something like this : class A { A() {} public : A(int=5) {} }; main() { A a;} KRUGER: dbkruger@ix.netcom.com (Dov Kruger ) No one really answered the direct question: The reason there is an error is NOT because there is ambiguity over which function the caller should call. The only function the caller would have the right to call is the public one, so there is no ambiguity about which function to call. The error message is confusing. CLAMAGE: clamage@Eng.sun.com (Steve Clamage), 1 Jul 96 Sorry, your analysis is not correct. The C++ rule has always been that overload resolution occurs before access is checked. You can find that rule in the ARM, and it is unchanged in the draft standard. You can also find the reason for that rule in the ARM and in "Design and Evolution". KRUGER: The problem is that the two functions mangle to the same name, and you have two different implementations for the same function. CLAMAGE: No, that is not correct either. The private constructor has no parameters, and the public constructor has one int parameter. The function types are different, and, assuming name mangling is used to implement function linkage (which is not a requirement), the names must be mangled differently. The error message is exactly right. Both constructors can be called without any explicit argument. (The compiler would supply an int argument of value 5 implicitly if the public version could be called unambiguously.) If an A constructor is invoked without any explicit argument, there is no way to choose between the constructors at the time function overloading is resolved. Generally speaking, default argument values and overloading don't mix very well -- there is too much chance for ambiguity, as in this example. Suggested design guideline: Provide just one function with default argument values, or provide overloaded functions having no default argument values.