Simple question

  • Thread starter Thread starter Smokey Grindle
  • Start date Start date
S

Smokey Grindle

Ok say I have a person class, a user class and a subuser class...

the person class is the base class, which implements the IPerson inerface...
which contains methods Update, create and remove..

now say the user class inherits the person class but also implements the
IUser interface... which has the same methods... update, create and remove
and so on for the sub user...

so I have an object now that is based on the sub user and I for some reason
casted it as a IPerson, and call the update method on it, it will run the
sub user's update methods correct? at least that is how I understand it to
work, it shouldn't run the base method, IPerson.Update's implementation...
is this correct? thanks!
 
Smokey Grindle said:
Ok say I have a person class, a user class and a subuser class...

the person class is the base class, which implements the IPerson
inerface... which contains methods Update, create and remove..

now say the user class inherits the person class but also implements the
IUser interface... which has the same methods... update, create and remove
and so on for the sub user...

so I have an object now that is based on the sub user and I for some
reason casted it as a IPerson, and call the update method on it, it will
run the sub user's update methods correct? at least that is how I
understand it to work, it shouldn't run the base method, IPerson.Update's
implementation... is this correct? thanks!

yep, if you instantiated the "user" object by calling the user's
constructor, you can assign it to a "IPerson" reference variable.
something like this...
Dim myUser as IPerson = new user() '** (user *is-a* IPerson )
as long as you call a method that is described in the IPerson interface, it
will run the overridden version described in the user class.
 
Smokey,

And it does not tell that your method is ambitious and you have to put the
right namespace before it?

Cor
 
Back
Top