0

In absence of this pattern, downcasting is needed in the derived classes. My question is does this pattern solve only the problem of downcasting? And why is downcasting bad compared to the alternative offered by Intelligent Childrean Design Pattern?

1 Answer 1

1

Intelligent children is used when there are two base classes at the root of separate but related class hierarchies. For example Widget and WidgetRenderer are the base classes and ListBoxWidget needs to be used by the draw() method of the ListBoxWidgetRenderer. So the draw() method will want to downcast the Widget pointer.

Downcasting is generally frowned on, so every fresh reader will have to be convinced that it's okay in a given situation. With this pattern the right pointer is made available at the right type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.