Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualNightCreature83

Posted 04 October 2012 - 04:06 PM

It isn't sliced, but if you tell C++ to return you a cEntity pointer that is what the compiler will interprete it as, in memory however it is still a cPlayer object. And any virtual function you you call on this cEntity object will actually execute the cPlayer version if you overrode them in cPlayer.
Try this in a debugger, take the address of the cEntity that is returned when your request the player object and stick it in a memory window. You will see that the fields beyond the cEntity ones are set to values of your cPlayer object.

#1NightCreature83

Posted 04 October 2012 - 04:05 PM

It isn't sliced, but if you tell C++ to return you a cEntity pointer that is what the compiler will interprete it as, in memory however it is still a cPlayer object. And any function you overrode in cPlayer that is also in cEntity will execute the cPlayer one not the cEntity one.
Try this in a debugger, take the address of the cEntity that is returned when your request the player object and stick it in a memory window. You will see that the fields beyond the cEntity ones are set to values of your cPlayer object.

PARTNERS