Top "Downcast" questions

Downcasting permits an object of a superclass type to be treated as an object of any subclass type.

Extend the existing C++ class

I'd like to add the extra functionality without changing the existing class. Say, class base{ public: int i; base(){i = 1;} …

c++ inheritance downcast
Downcasting a list of objects in C#

How can I downcast a list of objects so that each of the objects in the list is downcast to …

c# inheritance downcast
Downcasting using dynamic_cast returns null

I'm trying to cast a base class object to a derived class object with dynamic_cast, but dynamic_cast returns …

c++ dynamic-cast downcast
How can I do a safe downcast and prevent a ClassCastException

I have the following scenario: public class A { } public class B extends A { } public class C extends B { public void …

java casting downcast
Could not downcast using List class in Java

I've been searching for an answer for this but to no avail. My question is why is it not possible …

java generics collections downcast
Is it safe to downcast objects (not pointers) to their known derived type?

Would there be a danger of slicing result Compare(const Osp::Base::Object &obj1, const Osp::Base::Object &…

c++ downcast object-slicing