Connecting Tech Pros Worldwide Forums | Help | Site Map

overload

Tony Johansson
Guest
 
Posts: n/a
#1: Jul 23 '05
Hello!

I just wonder if it's possible to overload a method only by having a
different return type.

//Tony



Larry I Smith
Guest
 
Posts: n/a
#2: Jul 23 '05

re: overload


Tony Johansson wrote:[color=blue]
> Hello!
>
> I just wonder if it's possible to overload a method only by having a
> different return type.
>
> //Tony
>
>[/color]

No
Phlip
Guest
 
Posts: n/a
#3: Jul 23 '05

re: overload


> Tony Johansson wrote:
[color=blue][color=green]
> > I just wonder if it's possible to overload a method only by having a
> > different return type.[/color][/color]
[color=blue]
> No[/color]

Google "covariant return types".

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand



Victor Bazarov
Guest
 
Posts: n/a
#4: Jul 23 '05

re: overload


Phlip wrote:[color=blue][color=green]
>> Tony Johansson wrote:[/color]
>[color=green][color=darkred]
>>> I just wonder if it's possible to overload a method only by having a
>>> different return type.[/color][/color]
>[color=green]
>> No[/color]
>
> Google "covariant return types".[/color]

You may be thinking "override". The question, however, is about
"overload". The answer is still "no", Larry is correct.

V


Pete Becker
Guest
 
Posts: n/a
#5: Jul 23 '05

re: overload


Phlip wrote:[color=blue][color=green]
>>Tony Johansson wrote:[/color]
>
>[color=green][color=darkred]
>>>I just wonder if it's possible to overload a method only by having a
>>>different return type.[/color][/color]
>
>[color=green]
>>No[/color]
>
>
> Google "covariant return types".
>[/color]

No need. His answer is right. Read the question again. <g>

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Phlip
Guest
 
Posts: n/a
#6: Jul 23 '05

re: overload


Pete Becker wrote:
[color=blue]
> Phlip wrote:[/color]
[color=blue][color=green][color=darkred]
> >>>I just wonder if it's possible to overload a method only by having a
> >>>different return type.[/color][/color][/color]
[color=blue][color=green][color=darkred]
> >>No[/color][/color][/color]
[color=blue][color=green]
> > Google "covariant return types".[/color][/color]
[color=blue]
> No need. His answer is right. Read the question again. <g>[/color]

"Overload" would mean "within the same scope", but only if C++ directly
supported the "method" concept. It doesn't, we are fuzzy, and so "No" is too
short an answer.

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand


Pete Becker
Guest
 
Posts: n/a
#7: Jul 23 '05

re: overload


Phlip wrote:[color=blue]
> Pete Becker wrote:
>
>[color=green]
>>Phlip wrote:[/color]
>
>[color=green][color=darkred]
>>>>>I just wonder if it's possible to overload a method only by having a
>>>>>different return type.[/color][/color]
>
>[color=green][color=darkred]
>>>>No[/color][/color]
>
>[color=green][color=darkred]
>>>Google "covariant return types".[/color][/color]
>
>[color=green]
>>No need. His answer is right. Read the question again. <g>[/color]
>
>
> "Overload" would mean "within the same scope", but only if C++ directly
> supported the "method" concept. It doesn't, we are fuzzy, and so "No" is too
> short an answer.
>[/color]

Huh? "Overload," as it's defined in C++, only applies to names declared
"within the same scope." Doesn't matter whether C++ directly supports
the "method" concept, whatever that is.

But if you're right, then please point out at least one context in C++
in which overloading can be based solely on the return type.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Alf P. Steinbach
Guest
 
Posts: n/a
#8: Jul 23 '05

re: overload


* Phlip:[color=blue]
> Pete Becker wrote:
>[color=green]
> > Phlip wrote:[/color]
>[color=green][color=darkred]
> > >>>I just wonder if it's possible to overload a method only by having a
> > >>>different return type.[/color][/color]
>[color=green][color=darkred]
> > >>No[/color][/color]
>[color=green][color=darkred]
> > > Google "covariant return types".[/color][/color]
>[color=green]
> > No need. His answer is right. Read the question again. <g>[/color]
>
> "Overload" would mean "within the same scope",[/color]

Depending on what that means (?), a counter-example:

struct A
{
void foo() {};
};

struct B: A
{
using A::foo;
void foo( int ) {}
};

[color=blue]
> but only if C++ directly supported the "method" concept.[/color]

???

[color=blue]
> It doesn't, we are fuzzy,[/color]

???

[color=blue]
> and so "No" is too short an answer.[/color]

Yes, it would be prudent to include discussion of template functions
and also the dummy argument trick. However, most of us are usually too
lazy to go into the "what's probably the reason for the question and the
ways that can be achieved". At least, I am. ;-)

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Phlip
Guest
 
Posts: n/a
#9: Jul 23 '05

re: overload


Pete Becker wrote:
[color=blue]
> But if you're right, then please point out at least one context in C++
> in which overloading can be based solely on the return type.[/color]
[color=blue]
>sigh<[/color]

What I'm "right" about is the question is fuzzy, hence you can't just answer
"No".

I assure you I agree with you both, to the letter, on the details of
overloading and differing return types.

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand



Pete Becker
Guest
 
Posts: n/a
#10: Jul 23 '05

re: overload


Phlip wrote:
[color=blue]
> Pete Becker wrote:
>
>[color=green]
>>But if you're right, then please point out at least one context in C++
>>in which overloading can be based solely on the return type.[/color]
>
>[color=green]
>>sigh<[/color][/color]

Please be more careful with your attributions. That "sigh" was yours,
not mine.
[color=blue]
>
>
> What I'm "right" about is the question is fuzzy, hence you can't just answer
> "No".
>[/color]

Only if you're trying to obfuscate, which, given the doubletalk you
posted in your initial response, may well be the case. Those of us who
gave useful answers know exactly what the question meant.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Phlip
Guest
 
Posts: n/a
#11: Jul 23 '05

re: overload


Pete Becker wrote:
[color=blue]
> Only if you're trying to obfuscate, which, given the doubletalk you
> posted in your initial response, may well be the case.[/color]

My initial response was 'Google "covariant return types".'

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand


Pete Becker
Guest
 
Posts: n/a
#12: Jul 23 '05

re: overload


Phlip wrote:[color=blue]
> Pete Becker wrote:
>
>[color=green]
>>Only if you're trying to obfuscate, which, given the doubletalk you
>>posted in your initial response, may well be the case.[/color]
>
>
> My initial response was 'Google "covariant return types".'
>[/color]

Okay, in your subsequent reaponse. This one was simply wrong.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Phlip
Guest
 
Posts: n/a
#13: Jul 23 '05

re: overload


Pete Becker wrote:
[color=blue][color=green]
> > My initial response was 'Google "covariant return types".'[/color][/color]
[color=blue]
> Okay, in your subsequent reaponse. This one was simply wrong.[/color]

Then you could have given _me_ a useful answer, such as "did you mean
override?'

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand


Pete Becker
Guest
 
Posts: n/a
#14: Jul 23 '05

re: overload


Phlip wrote:[color=blue]
> Pete Becker wrote:
>
>[color=green][color=darkred]
>>>My initial response was 'Google "covariant return types".'[/color][/color]
>
>[color=green]
>>Okay, in your subsequent reaponse. This one was simply wrong.[/color]
>
>
> Then you could have given _me_ a useful answer, such as "did you mean
> override?'
>[/color]

PLONK.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Closed Thread