Relative Content

Tag Archive for c++polymorphism

Best way of passing back derived class pointer result from a class working on a set of base class pointers

I have an abstract Base class and multiple derived classes from that Base class representing different kinds of objects all having the same property of weight. The purpose of the Selector class is to select an object from the passed collection of (homogeneous) objects based on some algorithm that will use the weight (via getWeight API) as the input. The number of derived classes from Base will continue to increase in the future, and the Selector algorithm itself can also evolve, but the input parameters will remain unchanged.

Best way of passing back derived class pointer result from a class working on a set of base class pointers

I have an abstract Base class and multiple derived classes from that Base class representing different kinds of objects all having the same property of weight. The purpose of the Selector class is to select an object from the passed collection of (homogeneous) objects based on some algorithm that will use the weight (via getWeight API) as the input. The number of derived classes from Base will continue to increase in the future, and the Selector algorithm itself can also evolve, but the input parameters will remain unchanged.