0

Let's say I have a class `A' with lot's of methods (which I can't grasp eventually) including a lot of fluent interfaces (including operator overloads) – returning *this by reference – which could become more in a later API version or so on.

I'd like to inherit all that stuff in a class `B' which has additional (fluent) methods so that all fluent interfaces of `A' (I don't want really to care about) return *this references as they were of type `B'.

(How) Can I do that?

1 Answers1

0

After its been casted as its base type you get object slicing.

Say for object B b the this value is of type B*. When using its A member functions, this will be of the type A*. If you cast the A* as an A object you will lose reference to all of its B specific data during the partial assignment.

flakes
  • 21,558
  • 8
  • 41
  • 88