| Author |
Inheritance , dynamic binding?
|
Zeeman Chen
Greenhorn
Joined: Oct 30, 2003
Posts: 9
|
|
I cannot understand what's going on behind the code. the result is 3 MOVE if I hadn't written : v =d; // upcasting , safe runtime error since d= (Dog)v; downcasting unsafe. who can tell me what happend in memory after the following two lines? thanks in advance! v= d; d = (Dog)v;
|
If a man take no thought at what is distant, he will find sorrow near at hand. ~ Confucius
|
 |
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
|
|
One way to see for yourself how things work here is to rename move1(), move2(), and move3() all to move(). Then add some calls to move() from main() like this:
|
Java API Documentation
The Java Tutorial
|
 |
 |
|
|
subject: Inheritance , dynamic binding?
|
|
|