Hi everyone.I've got a question on dynamic cast.Dynamic_cast allows us to downcast a data type from one to a more specific one in the same hierarchy.
But why not declare the variable we need to the appropriate type during programming time rather than downcasting it at run time?
I don't think that the developers of C++ included dymanic_cast by mistake or for the sake of commands redundancy... Then why? What's its additional use and benefits??
Jump to Post
When you need it, you'll have your answers.
>But why not declare the variable we need to the appropriate type
>during programming time rather than downcasting it at run time?
Because that might not be practical. Consider an array of base class pointers with varying dynamic types down the …
All 4 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.