473,466 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

about overlloading

Hello!

I'm reading a book and it say that I might get compile error if I overload
these two myMethods below.
I have testet but I don't get any compile error and the application work as
expected in run time.

I just wonder why the book say that I might get compile error,
I just wonder either it's correct or not correct to overload in this way.
I think that the compiler should be able to distinguish between these two it
so it does.

int myMethod(int);
int myMethod (int[]);

//Tony


Jun 2 '06 #1
2 1019
Tony,

I don't know why it said you would get a compiler error. I don't see
how. There is no violation of the language here. An array of a type is a
separate type than the type itself. Because of that, the signatures will
always vary, and you will never get a compiler error.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tony Johansson" <jo*****************@telia.com> wrote in message
news:Jy****************@newsb.telia.net...
Hello!

I'm reading a book and it say that I might get compile error if I overload
these two myMethods below.
I have testet but I don't get any compile error and the application work
as expected in run time.

I just wonder why the book say that I might get compile error,
I just wonder either it's correct or not correct to overload in this way.
I think that the compiler should be able to distinguish between these two
it so it does.

int myMethod(int);
int myMethod (int[]);

//Tony


Jun 2 '06 #2
> > I'm reading a book and it say that I might get compile error if I overload
these two myMethods below.
I have testet but I don't get any compile error and the application work
as expected in run time.

I just wonder why the book say that I might get compile error,
I just wonder either it's correct or not correct to overload in this way.
I think that the compiler should be able to distinguish between these two
it so it does.

int myMethod(int);
int myMethod (int[]);

//Tony


You will not get a compiler error. You _would_ get a compiler error if
you attempted to overload like this:

int myMethod(int);
int[] myMethod(int);

because the parameters are the same in both cases. You cannot overload
changing only the return type.

However, the original code you posted compiles correctly, as you stated.

Jun 2 '06 #3

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

Similar topics

1
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
8
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
77
by: nospam | last post by:
Reasons for a 3-tier achitecture for the WEB? (NOTE: I said, WEB, NOT WINDOWS. DON'T shoot your mouth off if you don't understand the difference.) I hear only one reason and that's to switch a...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
5
by: eScrewDotCom | last post by:
www.eScrew.com eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is...
0
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
7
by: Edward Yang | last post by:
A few days ago I started a thread "I think C# is forcing us to write more (redundant) code" and got many replies (more than what I had expected). But after reading all the replies I think my...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.