c++ – Represent individual object as a class?

I understand that the classes represent not particular objects but “groups”/”generalizations” of objects.

Classes represent types of objects. They’re part of the type system.

So if Garfield is a distinct type of cat, with different properties or logic than another cat, it might be a type, and you might represent that type with a class.

If Garfield is just a cat with a particular name – and maybe other specific values for normal cat-type attributes … it’s an instance of the same class.


class Garfield: public Cat {
  double lasagnaDeficit_; // property unique to Garfield

but if cats already have a favourite food, it might just be:

Cat *Garfield = new Cat("Garfield", /*favourite food*/ "Lasagna");