Apr-10-2024, 10:10 AM
(Apr-10-2024, 08:39 AM)Gribouillis Wrote: I think multiple inheritance should be used warily and possibly not at all, an exception being the case of mixin classes.
In your code, the intention behind the classes is not obvious, so it is difficult to give a clear advice. However, remember that inheritance means the ISA relationship, but in your case, I'd tend to believe that the StaticObject is a CollisionObject having a certain shape. Its relation to shape is more HAS-A shape than IS-A shape. If this is true, you could replace inheritance with composition, which is usually considered a better design...
Thank you for your reply. I originally structured my code with IS-A relations, but in the example code my professor gave me there were a lot of HAS-A relations, hence why I changed it. I think I will revert my code back to the IS-A relations I used to have.
Thank you for your help!