I would like to understand what g++ is doing in the following case a little better, in the hope of not beating my head into a wall for 2 days again.
=======Start of sample code=================== #include <iostream> class A { public: int foo(unsigned int x) const { std::cout << "foo(unsigned int x) const\n"; return 1; } int foo(void* x) { std::cout << "foo(void* x)\n"; return 1; } }; int main() { A a; // calls foo(void* x) a.foo(0); // calls foo(unsigned int x) const unsigned int x = 0; a.foo(x); // the following will trip an ambiguity error //a.foo((unsigned int)0); // calls foo(unsigned int x) const a.foo(1); a.foo(2); return 0; } ====================================== Output: foo(void* x) foo(unsigned int x) const foo(unsigned int x) const foo(unsigned int x) const ====================================== My main question has to be why 0 is treated as void* but any other number won't be. Is this because 0 is NULL and a pointer is basically an unsigned int? (or am I completely off base with this) The second would be why the cast causes an ambiguity but not a.foo(x). _______________________________________________ Help-gplusplus mailing list Help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus