Problem with Constructor

  • Thread starter Thread starter shapper
  • Start date Start date
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
 
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
 
Back
Top