I have 3 classes MovableObject
, FixedObject
and CollisionObject
. A CollisionObject
should have the possibility to be either a MovableObject
or a FixedObject
. But it would make no sense to use multiple inheritance, as it can't be both at the same time. Basically, if I create a Projectile
, the hierarchy would be:
Sprite <- MovableObject <- CollisionObject <- Projectile
And if I create an Obstacle
it would be:
Sprite <- FixedObject <- CollisionObject <- Obstacle
(My base class is Sprite
)
So what CollisionObject
should inherit from is decided by what the child objects inherits from (Either a Movable-
or FixedObject
). But how do I implement this in C++ in a nice way?