M
Marty McDonald
I know about boxing & unboxing... but I'd like to know just a bit more. For
instance, Dog is derived from Animal. Dog has a method called "Bark".
Assume we're calling a method like this...
Dog spot = new Dog();
DoStuff(spot);
The method looks like this...
private void DoStuff(Animal a)
{
Dog d = (Dog)a;
}
"a" points to a Dog object, but it can only "see" methods for Animal. Then
we make "d" point to that same object and cast it to a Dog, and suddenly we
"see" the "Bark" method. Is there a table of method pointers being used
here? "a" only sees the first few pointers, but "d" sees those plus the
remaining pointers? Are the Dog method pointers stored right after the
Animal method pointers? Just curious... Thanks! --Marty
instance, Dog is derived from Animal. Dog has a method called "Bark".
Assume we're calling a method like this...
Dog spot = new Dog();
DoStuff(spot);
The method looks like this...
private void DoStuff(Animal a)
{
Dog d = (Dog)a;
}
"a" points to a Dog object, but it can only "see" methods for Animal. Then
we make "d" point to that same object and cast it to a Dog, and suddenly we
"see" the "Bark" method. Is there a table of method pointers being used
here? "a" only sees the first few pointers, but "d" sees those plus the
remaining pointers? Are the Dog method pointers stored right after the
Animal method pointers? Just curious... Thanks! --Marty