class A{
public:
void foo(int x)
{
cout << \"foo with one\\n\";
}
void foo(int x, int y=10)
{
No you cannot overload functions on basis of value of the argument being passed, So overloading on the basis of value of default argument is not allowed either.
You can only overload functions only on the basis of:
const
and volatile
.Ofcourse, Whether the overload is accepted by the compiler depends on the fact:
If the compiler resolve calling of the function unambiguously.
In your case, the compiler cannot resolve the ambiguity, for ex: The compiler wouldn't know which overloaded function to call if you simple called the function as:
foo(100);
The compiler cannot make the decision and hence the error.