Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8246621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:34:00+00:00 2026-06-07T22:34:00+00:00

Is the only point in implementing the 2nd case is if I want to

  • 0

Is the only point in implementing the 2nd case is if I want to derive from a Collidable without being an Object? If that’s the case, when is the 1st case ever favorable since the 2nd case offers more flexibility.

Both collidables have only a pure virtual function and Object is a base class for objects that can be drawn on the screen (in my case).

^Assuming I’m understanding the following code correctly (I’m not too sure 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

First example is the second case and second example is the first case. I guess thats the only use I see for the first case.

@Luchian
This is going to be a different question from the original since your reply was neither.

In this case, is there a difference changing an object from a is-a to a has-a relationship? In each case, to check for collisions, an object has to has to have a flag to know if collision should be checked. In your case, the member can be checked if its null or not, but in the derived case, the object itself tells whether it can collide or not. In an array/tree, I can either pass the derived object as a argument or pass hitbox as an argument using a get() method.

To be more in depth, I have another class – using the second case

class Hitbox : public Object, public Collidable

and the Actor class has it as a member

class Actor : public Object
{
     Hitbox *box;
};

Objects that have collision would have a hitbox instead and this represents your post accurately I think. But what’s still getting me is that when I review your example again, does it mean that Hitbox should have a Collidable member instead?

class Hitbox
{
     Collidable *collision;
};

What I have:
An Actor holds a Hitbox which handles collision

What Hitbox should do:
Inherit Collidable or
Have Collidable as a member

Actor is already following your convention. Should Hitbox do the same?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:34:01+00:00Added an answer on June 7, 2026 at 10:34 pm

    I would do the second case, as Object and Collidable are cross-cutting concerns. If you go the CollidableObject route, you will probably end up with a combinatorial explosion of classes. It won’t be long until you see a CollidableTrackableClickableBlowuppableObject.

    Since Collidable is pure virtual, it is used in this case as an interface, so doesn’t have many of the criticisms that argue against multiple inheritance. You are simply stating that an Actor implements the Collidable interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to open an NSStream to a wifi access point that has only
I want to make sure that I only print maximum 80 character long lines,
So by now I'm getting the point that we should all be implementing our
We are implementing an emulator for a piece of hardware that is being developed
I'm implementing accordion-style behavior, where only one element can be displayed at one point.
I'm implementing a feature that when the user press on any point in the
I'm implementing highcharts in my site, however is proving challenging from a presentation point
I am implementing a class that will be used concurrently from multiple threads. Most
I'm not asking someone to make a script for me, only to point me
How I can draw bezier curve in canvas. I have only start point and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.