Consider:
// member data omitted for brevity
// assume that \"setAngle\" needs to be implemented separately
// in Label and Image, and that Button does need
I think (I haven't tested it) this will do it using templates:
template struct TWidget {
T& move(Point newPos) { pos = newPos; return (T&)*this; }
};
template struct TLabel : TWidget { ... }
struct Label : TLabel
Notes:
LabelT and Label classes).dynamic_cast if you like.return *this", the base class could contain a T& as a data member (the derived class would pass this to the base class' constructor), which would be an extra data member, but which avoids a cast and I think may permit composition instead of or as well as inheritance.