Comment

Comment by haberman

You can explain is-a using examples that actually make sense to model using inheritance, like a set of game objects that have an interface like:

    class GameObject {
     public:
      // Called every frame to update the object's logical state.
      void Update(GameState* state);

      // Called to draw the object.
      Draw(GraphicsContext* context);
    }

    class EnemySpaceship : public GameObject { /* ... */ };
    class SpaceDebris : public GameObject { /* ... */ };
The point is to move the discussion into the practical reasons for introducing inheritance, rather than to make it a pointless ontological exercise of whether a Square is-a Rectangle or vice-versa.
parent haberman 15 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton