Is the only point in the implementation of the second case if I want to get from Collidable without being an object? If this is the case when it is the 1st case, it is ever favorable, since the second case offers great flexibility.
Both collidables have only a pure virtual function, and Object is the base class for objects that can be drawn on the screen (in my case).
^ Assuming I understand the following code correctly (I'm not sure about TBH)
class Object class CollidableObject : Object class Actor : public CollidableObject class Object class Collidable class Actor : public Object, public Collidable
Edit:
Based on Matt / Seth
class Object class Collidable class Clickable class Trackable class BlowUppable class Actor : public Object, public Collidable, public Clickable, public Trackable, public BlowUppable class SomeObjectThatIsTakenForGrantedThatEverythingElseIsInherited : public Actor
The first example is the second case, and the second example is the first case. I assume this is the only use I see for the first case.
@Luchian
This will be a different question from the original, since your answer was neither one nor the other.
In this case, is there a difference that changes an object from an is-a to aa relationship? In each case, in order to check for collisions, the object must have a flag to know whether to check for a collision. In your case, the member can be checked if it is zero or not, but in the derived case the object itself reports whether it can collide or not. In an array / tree, I can either pass the derived object as an argument, or pass hitbox as an argument using the get () method.
To be deeper, I have another class - using the second case
class Hitbox : public Object, public Collidable
and the class Actor has it as a member
class Actor : public Object { Hitbox *box; };
Objects that have a collision will have a hitbox instead, and this represents your message for sure, I think. But what else causes me is that when I look at your example again, does this mean that the Hitbox must have a Collidable member?
class Hitbox { Collidable *collision; };
What I have:
The actor has a hitbox that handles the collision
What Hitbox should do:
Inherit collidable or
Affects as a member
The actor is already following your convention. Should Hitbox do the same?