// Pure virtual interface
class IPhysicsBody { virtual void addToScene() = 0; };
class IPhysicsRigidBody : public IPhysicsBody {};
class IPhysicsDynamicRigidBody : public IPhysicsRigidBody {};
// Implementation
class IPhysicsPhysXRigidBody : public IPhysicsRigidBody { virtual void addToScene(); };
class PhysicsPhysXDynamicRigidBody : public IPhysicsDynamicRigidBody, public IPhysicsPhysXRigidBody {};
Instance of PhysicsPhysXDynamicRigidBody can't be created, because IPhysicsBody::addToScene is abstract. Yet there is an available implementation in IPhysicsPhysXRigidBody which the class inherits too. I could implement PhysicsPhysXDynamicRigidBody::addToScene() and call the parent implementation this way, but that's alot of extra work and deforms the implementation. Is there a way to solve this? Maybe rearranging my class hierarchy? This is the first time I've encountered this problem.
The short answer is no. The long answer is you could take two paths: 1) use virtual inheritance but that has its own nuances which might cause you more trouble than it's worth; 2) use static polymorphism based on templates but that means turning most of your classes into templates with all related consequences.
Thank you for your quick reply Sir. I didn't even know virtual inheritance, will take a look at it. Templates would over-engineer the problem here, i guess.