473,411 Members | 2,014 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,411 software developers and data experts.

Overload resolution vs. Enum's

I have two routines

Public Sub Log( ByVal e as eLogLevel, ByVal saMsg as String )
Public Sub Log( ByVal i as Integer, ByVal saMsg as String )

(eLogLevel is a Public Enum)
(We started off with the Integer method, then wanted to add the
Enum overload to clarify the values that should be fed in).

Provided I call /each/ of these overloads with the /correct/ type in
the first argument, I get the correct version being called. However,
if (as many of my lot do), I use

o.Log( 0, "message" )

the compiled (I.L.) code shows the [first] Enum overload being called
and /not/, as I would have expected, the Integer one. Any value other
than zero correctly uses the Integer overload, so why does zero pick
the wrong one?

(I'm using VB.Net, VS 2003, v7.1.3088)

TIA,
Phill W.
Nov 21 '05 #1
1 1332
Very interesting point indeed. Here's a good discussion on this topic which
should hopefully 'resolve' this for you:
http://groups-beta.google.com/group/...f674dcc5f74591

hope that helps..
Imran.

I have two routines

Public Sub Log( ByVal e as eLogLevel, ByVal saMsg as String ) Public
Sub Log( ByVal i as Integer, ByVal saMsg as String )

(eLogLevel is a Public Enum)
(We started off with the Integer method, then wanted to add the
Enum overload to clarify the values that should be fed in).
Provided I call /each/ of these overloads with the /correct/ type in
the first argument, I get the correct version being called. However,
if (as many of my lot do), I use

o.Log( 0, "message" )

the compiled (I.L.) code shows the [first] Enum overload being called
and /not/, as I would have expected, the Integer one. Any value other
than zero correctly uses the Integer overload, so why does zero pick
the wrong one?

(I'm using VB.Net, VS 2003, v7.1.3088)

TIA,
Phill W.


Nov 21 '05 #2

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

Similar topics

9
by: Alexander Stippler | last post by:
Hi, I have got a question concerning the overload resolution rules of C++ and enumeration types. The following little test program illustrates the situation: enum { red, green, blue }; ...
8
by: David Sachs | last post by:
The following program illustrates an interesting effect of the way C++ resolves function overloading. I have verified with a member of the C++ stardard committee that the output shown is...
13
by: Vladimir Granitsky | last post by:
Hi guys, Please, look at the code below and try to step into it. The compiled code calls the loosely typed method public void Method1(object o) !?!? Am I right that C# compiler does wrong...
0
by: Eph0nk | last post by:
Hi, I get an overload resolution failed error (Overload resolution failed because no accessible 'New' can be called without a narrowing conversion), and I can't seem to find a lot of relevant...
2
by: Michi Henning | last post by:
Hi, the following code produces an error on the second-last line: Interface Left Sub op() End Interface Interface Right Sub op(ByVal i As Integer)
3
by: Christof Nordiek | last post by:
Given the following code Is there any way to call one of the Bar methods. using System; class Program { static void Main() { Foo<string, stringfoo = new Foo<string,string>();
2
by: xtrigger303 | last post by:
Hi to all, I was reading Mr. Alexandrescu's mojo article and I've a hard time understanding the following. Let's suppose I have: //code struct A {}; struct B : A {};
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...
2
by: zbigniew | last post by:
Can someone explain me how overload resolution works in C++? For example if I have function void f(char, int); and I will call f('A', 3.1) or f(1.5, 3.1F) what would be the result? Thanks
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.