Problem with Constructor

S

shapper

Hello,

I am creating a class but somehow I think I am not getting the
constructors right.
I get the error:

"Public Overloads Sub Add has multiple definitions to with identical
signatures"

Can you tell me how to solve my problem?

Public Overloads Sub Add(ByVal name As String, ByVal city As
String)
Select(name, city)
End Sub ' Add

Public Overloads Sub Add(ByVal name As String, ByVal country As
String)
Select(name, country)
End Sub ' Add

Is seems they are considered equal even if the variables city and
country are different.

How to solve this problem?

Thanks,
Miguel
 
K

Karl Seguin

Overrloading works based on the # of parameters and the TYPE of arguments..

the compiler sees:

Add(string, string) in both cases...


If someone does

Add("test", "test")

how is the compiler supposed to know which of the two overloads to call?


one solution to your problem is to use distinct function names, AddCity and
AddCountry

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top