If you can't make setGridSize
a virtual function in the parent then you might want to add a function that simply casts m_piston
to RectangularPiston*
then call this function when your class needs to refer to m_piston
.
RectangularPiston* getRecPiston() {
return static_cast<RectangularPiston*>(m_piston);
}
bool setGridSizeOfPiston(...) {
return getRecPiston()->setGridSize(...)
}