Class Inheritance not default

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

If I have the following classes:

public class Person
{
....
public Person()
{
...
}

public Person(int userID)
{
...
}
....
}


public class User : Person
{
....
public User()
{
...
}

public User(int userID)
{
...
}
....
}

In my program I create a User object like so:

Dim user = New User(1)

My problem is that I need to pass the userID which is being passed to User
to Person as well so it can get the Person record using userID as the key.
I would then get the User record also using the userID key.

The problem is that when I do the instantiation, it goes to User and then
directly to Person and its default constructer and not the one with the
userID being passed.

How do I get it to go to the correct constructor using inheritance?

Thanks,

Tom
 
public class User : Person
{
//...
public User()
: base()
{
// ...
}

public User(int userID)
: base(userID)
{
// ...
}
// ....
}

-Drew
 
DrewCE said:
public class User : Person
{
//...
public User()
: base()
{
// ...
}

public User(int userID)
: base(userID)
{
// ...
}
// ....
}

That did it.

Thanks,

Tom
 
Back
Top