Topic: Overlo[a]ding by return value
Author: meixner@rbg.informatik.tu-darmstadt.de (Matthias Meixner)
Date: 2000/06/13 Raw View
Jonathan de Boyne Pollard (J.deBoynePollard@tesco.net) wrote:
) BG> Why does c++ not support overloading by return value?
) BG>
) BG> class A {
) BG> public:
) BG> float f();
) BG> double f();
) BG> };
)
) int
) main ()
) {
) A a ;
) long double ld = a.f() ; // Which A::f is called ?
) }
)
Renaming the funtions: float f() -> operator float(), double f() -> operator double()
and answering that question, it is already covered by the current standard:
The call would be ambiguous according to overload resolution.
- Matthias Meixner
--
Matthias Meixner meixner@rbg.informatik.tu-darmstadt.de
Technische Universit t Darmstadt
Rechnerbetriebsgruppe Telefon (+49) 6151 16 6670
Wilhelminenstra e 7, D-64283 Darmstadt, Germany Fax (+49) 6151 16 4701
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]