Skip to content
UPEEC

dynamic_cast

Safely downcast a base pointer/reference to a derived type, checking at run time.

Intermediate
Comments 0

if (auto* m = dynamic_cast<Motor*>(dev)) m->set_speed(50); returns nullptr on failure.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.