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??
tlly 0 Newbie Poster
Recommended Answers
Jump to PostWhen 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
Narue 5,707 Bad Cop Team Colleague
dubeyprateek 26 Junior Poster
sahu74 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.