Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inheritance , dynamic binding?

 
Zeeman Chen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;


 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic