3 ms·
Yes, downcasting performs dynamic type checking. There are no two ways about it. C++ correctly calls this `dynamic_cast`. The only way to completely avoid dynam
by sparkie 4y ago
Yes, downcasting performs dynamic type checking. There are no two ways about it. C++ correctly calls this `dynamic_cast`. The only way to completely avoid dynamic type checking in such object hierarchies is to forbid downcast completely, as OCaml does, for example.
Most "statically typed" OOP languages have this escape hatch for dynamic typing because it is very useful, and is usually only performed after a check for the correct type has been performed. or if it is known by the programmer that the correct type is present, but there is no way to express this knowledge in the type system.