Consider the program
#include <iostream>
using namespace std;
void fn(const char * str, char x = 'Y')
{
cout << "from fn(const char *, char) - " << str << endl;
return;
}
void fn(const char * str)
{
cout << "from fn(const char *) - " << str << endl;
return;
}
int main( )
{
// fn("test string");
return 0;
}
This program compiles without any error or warning. If I remove the
comment in the statement
// fn("test string");
in main( ), I am getting ambiguity error. Why doesn't the compiler
detect the ambiguity even when the call to fn( ) was not made ? What
is the expected behaviour ? Where am I going wrong ?
Kindly explain.
Thanks
V.Subramanian