Article View: comp.std.c++
Article #3679Static member functions and overloading resolution
From: Emmanuel Lesueur
Date: Fri, 15 Mar 1996 00:48
Date: Fri, 15 Mar 1996 00:48
39 lines
1903 bytes
1903 bytes
Consider the following situation:
class A {
public:
void f(int);
static void f(char);
};
class B : public A {
};
void foo(B& b,char c) {
b.f(c);
}
Here, the candidates functions for overloading resolution are
f(const A&,int) and f(?,char) where '?' matches any type,
and the call arguments have types B& and char.
The first candidate needs a conversion from B& to const A& for the
first argument while the second is an exact match. The second
candidate has an exact match for the first argument while the
second requires a char->int promotion. Therefore, the call
is ambiguous.
Is the above correct, or did I miss something ?
If I understood correctly, is this the intended behaviour ?
If so, why ?
I think selecting f(char) would make more sense here (and that's
what the compilers I have tested do).
___________________________________________________
Emmanuel Lesueur - elesueur@ens-lyon.fr
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. 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 ]
Technical Details
Message-ID:
<4i9rbn$fgj@cri.ens-lyon.fr>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backShow Full Headers
Complete Article Headers
From: elesueur@ens-lyon.fr (Emmanuel Lesueur) Message-ID: <4i9rbn$fgj@cri.ens-lyon.fr> X-Original-Date: 14 Mar 1996 19:17:11 GMT Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 15 Mar 96 00:48:43 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Subject: Static member functions and overloading resolution Organization: Ecole Normale Superieure de Lyon, France Reply-To: elesueur@ens-lyon.fr X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMUi+jOEDnX0m9pzZAQHVzwF+LJwTYyyD24StyXA849CY/xjJ7tulbc3d eZYkmH1OWVwf011ZD8OHjXRQsukQG+pq =uWU+