14. Casting

Reasonable men do not change the world.

– G.B.Shaw

Major and minor extensions — the need for run-time type information (RTTI) — dynamic_cast — syntax — which types support RTTI — casting from a virtual base — uses and misuses of RTTI — typeid() — class type_info — extended type information — a simple object I/O system — rejected alternatives new casts — static_castreinterpret_castconst_cast — using new-style casts.

14.1 Major Extensions

Templates (§15), exceptions (§16), run-type type information (§14.2), and name-spaces (§17) are often referred to as major extensions. What makes them major -whether seen as extensions or as integral features of C++ – is that they affect the way programs can be organized. Since C++ was created ...

Get The Design and Evolution of C++, First Edition 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.