Topic: pointer conversions from the null pointer constant
Author: balu@netcom.com (Balasubramanian)
Date: 1996/02/20 Raw View
Given the following:
class A {};
class B : public A {};
class C : public B {};
void foo(A*) { ... }
void foo(C*) { ... }
int main() {foo(0); return 0;}
How is the call to foo() in main() to be resolved? It seemed obvious
to me that the call should be ambiguous but some compilers resolve
it as a call to foo(C*) (while others reject it as ambiguous.)
Is the conversion of the null pointer constant to C*
better than its conversion to A*? I couldn't find anything
in the ARM or the draft standard (May 1995) to support this
interpretation.
Thanks.
- balu
---
[ To submit articles: Try just posting with your newsreader. If that fails,
use mailto:std-c++@ncar.ucar.edu
FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
Comments? mailto:std.c++-request@ncar.ucar.edu
]