Overloading functions with default parameters will cause compile error for ambiguous calling on the overloaded function. But it really depends on the signatures of the overloaded function. If you don't call the overloaded function, as long as the signatures are different, it compiles fine. When you call them, you can not omit all the parameters because of ambiguity issue.
void PrintValues(int nValue1=10, int nValue2=20, int nValue3=30)
{
using namespace std;
cout << "IValues: " << nValue1 << " " << nValue2 << " " << nValue3 << endl;
}
double PrintValues(double fValue1= 1.1, double fValue2=2.2, double fValue3=3.3)
{
using namespace std;
cout << "FValues: " << fValue1 << " " << fValue2 << " " << fValue3 << endl;
return 99.9;
}
int main(int argc, char* argv[])
{
PrintValues(1, 2, 3);
PrintValues(1, 2);
PrintValues(1);
//PrintValues(); // this will causing ambiguity
PrintValues(88.88); // this is fine
return 0;
}
So generally, you don't want to do this.