Casting with runtime checks

The dynamic_cast operator is used to convert pointers between related classes, and for this reason it will be explained in Chapter 6, Classes. This operator involves runtime checks so that the conversion is only performed if the operand can be converted to the specified type. If the conversion is not possible then the operator returns nullptr, giving you an opportunity to only use converted pointers that point to an actual object of that type.

Get Beginning C++ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.