Translations:Demystifying C++ - Classes/9/en

From emmtrix Wiki
Jump to navigation Jump to search
  • Derived-to-Base Casts: In assembler, such a cast corresponds to an addition with a constant value. These are relatively simple to implement in C by accessing the respective field in the derived structure. This happens implicitly in C++ in many places, such as when calling base class methods or accessing attributes.
  • Static Base-to-Derived Casts: In assembler, such a cast corresponds to a subtraction with a constant value. This is more complex in C and requires some C casting.
  • Dynamic Base-to-Derived Casts: These are produced with the dynamic_cast keyword and are more complex in implementation since they require type checking at runtime. Dynamic casts will be discussed in the chapter on virtual classes.