473,387 Members | 1,283 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

overload

Hello!

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

//Tony
Jul 23 '05 #1
13 1649
Tony Johansson wrote:
Hello!

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

//Tony


No
Jul 23 '05 #2
> Tony Johansson wrote:
I just wonder if it's possible to overload a method only by having a
different return type.
No


Google "covariant return types".

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

Jul 23 '05 #3
Phlip wrote:
Tony Johansson wrote:

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

No


Google "covariant return types".


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

V
Jul 23 '05 #4
Phlip wrote:
Tony Johansson wrote:


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


No

Google "covariant return types".


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

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 23 '05 #5
Pete Becker wrote:
Phlip wrote:
I just wonder if it's possible to overload a method only by having a
different return type. No
Google "covariant return types".

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


"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
Jul 23 '05 #6
Phlip wrote:
Pete Becker wrote:

Phlip wrote:


>I just wonder if it's possible to overload a method only by having a
>different return type.
No
Google "covariant return types".


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

"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.


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)
Jul 23 '05 #7
* Phlip:
Pete Becker wrote:
Phlip wrote:
>>I just wonder if it's possible to overload a method only by having a
>>different return type.No Google "covariant return types".

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


"Overload" would mean "within the same scope",


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

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

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

but only if C++ directly supported the "method" concept.
???

It doesn't, we are fuzzy,
???

and so "No" is too short an answer.


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?
Jul 23 '05 #8
Pete Becker wrote:
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. sigh<


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

Jul 23 '05 #9
Phlip wrote:
Pete Becker wrote:

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.
sigh<


Please be more careful with your attributions. That "sigh" was yours,
not mine.


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


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)
Jul 23 '05 #10
Pete Becker wrote:
Only if you're trying to obfuscate, which, given the doubletalk you
posted in your initial response, may well be the case.


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

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #11
Phlip wrote:
Pete Becker wrote:

Only if you're trying to obfuscate, which, given the doubletalk you
posted in your initial response, may well be the case.

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


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

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 23 '05 #12
Pete Becker wrote:
My initial response was 'Google "covariant return types".'
Okay, in your subsequent reaponse. This one was simply wrong.


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

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #13
Phlip wrote:
Pete Becker wrote:

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


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

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


PLONK.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 23 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Piotre Ugrumov | last post by:
I have tried to implement the overload of these 2 operators. ostream & operator<<(ostream &out, Person &p){ out<<p.getName()<<" "<<p.getSurname()<<", "<<p.getDateOfBirth()<<endl; return out; }...
1
by: Piotre Ugrumov | last post by:
I'm following your help. I have written the overload of the operator <<. This overload work! :-) But I have some problem with the overload of the operator >>. I have written the overload of this...
3
by: Piotre Ugrumov | last post by:
I have done the overload on the operator >> and << in the class Attore. These 2 overload work correctly. I have done the overload of the same overload in the class Film. The class film ha inside...
4
by: Chiller | last post by:
Ok, thanks to some good assistance/advice from people in this group I've been able to further develop my Distance class. Since previous posts I've refined my code to accept the unit measurement...
9
by: Mario Charest | last post by:
.. Hi, It's possible to overload the operator, but I wonder if it's possible to somehow overload and so forth. My goal would be to switch from static array declaration into something...
17
by: Chris | last post by:
To me, this seems rather redundant. The compiler requires that if you overload the == operator, you must also overload the != operator. All I do for the != operator is something like this: ...
10
by: shachar | last post by:
hi all. can i OverLoad Operators - such as Exclamation Mark "!" ? how?
9
by: Tony | last post by:
I have an operator== overload that compares two items and returns a new class as the result of the comparison (instead of the normal bool) I then get an ambiguous operater compile error when I...
3
by: i3x171um | last post by:
To start off, I'm using GCC4. Specifically, the MingW (setjmp/longjmp) build of GCC 4.2.1 on Windows XP x64. I'm writing a class that abstracts a message, which can be either an integer (stored as...
5
by: jknupp | last post by:
In the following program, if the call to bar does not specify the type as <int>, gcc gives the error "no matching function for call to ‘bar(A&, <unresolved overloaded function type>)’". Since bar...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.