Radde wrote:
class A
{
public:
void fun(int* p)
{
cout<<"fun(char* )"<<p<<endl;
}
void fun(int i)
{
cout<<"f(int)"<<i<<endl;
}
};
void main()
main() must return int. Your program has undefined behaviour.
{
A a;
a.fun(NULL);
}
Why my function call i.e a.fun(NULL) always calls fun(int), but not
fun(int* i)?? Is it not the ambiguity..
Actually, NULL is not defined at all in your program, just like cout and
endl. Maybe you forgot to copy some #include lines to your posting?
Anyway, the NULL defined in the C++ standard library is a macro that expands
to an integer. So the version taking an int is chosen, because it's a
better match. Generally, you should avoid using NULL for this reason (among
others).