Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is crucially desired here is the answer to “Is it safe to use the derived class object? Does it even exist?

0
Posted

What is crucially desired here is the answer to “Is it safe to use the derived class object? Does it even exist?

0

In particular, the thrust is that dynamic_cast provides direct language support by accepting a pointer or reference to a base class object (the one in the “closed library”), and respectively rendering (converting) it as a pointer or reference to a particular derived class (yours), all at runtime. Note that the cast sought is in the opposite direction from earlier. This base to derived conversion is downcasting, as it is casting down the inheritance diagram. Downcasting behavior does not happen implicitly. With upcasting you are normally zeroing in on a specific ancestral base class, usually quite clearly, even considering multiple inheritance. However, with downcasting, since it fans out, the breadth of the choices expands unlimitedly, and worse, the classes become less general and more specific since this is how derived classes for different niches work and are often for. For instance, we can keep adding derived Shapes to the classic example given above. This should “just work” and no

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123