Overloading based on return type



 DEVELOP > c-Plus-Plus > Overloading based on return type

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Madhav"
Date: 13 Aug 2007 01:48:20 AM
Object: Overloading based on return type
Hi All,
Very recently I had one iteresting question about
overloading. The guy was arguing why we dont have overloading based on
return type. I told him about the reason mentioned in "Thinking in C+
+", which is what if the return type is ignored by the caller.
He then said that the regular overloading places
restrictions - such as same fucntion names, different type or number
of arguments. If the language creators wanted to implement
overloading, they could have forced the restriction of specifiying the
return type each time the caller ignores that function.
I request everyone to comment on this. I really want to find
out why overloading is not supported on the basis of return type of
the function.
Regards,
Madhav.
.

User: ""

Title: Re: Overloading based on return type 13 Aug 2007 02:48:12 AM
On Aug 13, 3:48 pm, Madhav <madhav.kel...@gmail.com> wrote:

I really want to find
out why overloading is not supported on the basis of return type of
the function.

Google's a wonderful thing - from Stroustrup himself:
The reason that C++ doesn't allow overload resolution based on a
return
type (so that you need to use explicit qualification in the examples
below) is that I wanted overload resolution to be bottom up. For
example, you can determine the meaning of a subexpression a+b without
considering the complete expression that a+b is part of. Overload
resolution can be subtle so even though I knew how to use return types
as part of resolution (Ada showed how), I decided not to. As a result
of this decision, a+b means the same in a+b+c as in a+b+d. See
Stroustrup: The Design and Evolution of C++ for more details of the
design of C++.
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER