How does virtual/override interact with casting? ie Casting won't stop overrides

I came upon something confusing when I started thinking about how damage is done.

Suppose you override AActor’s TakeDamage in your tank class, but then you call

Cast<AActor>(MyTank)->TakeDamage(params…)

I have tested this in a small console app, and it seems that even after casting to AActor, the Tank class version of the TakeDamage function is called. In other words, casting won’t stop overrides. Please correct me if I am wrong…

Privacy & Terms