[Solved] What’s the difference between enumerators, structs and classes? [closed]


Modern C++ treats structs and classes the same, the only difference is that structs default to public while classes default to private. They are basically collections of data with associated functionality.
For example

class Player
{
   private:
      int health;
      int attack;
   public:
      void calculateHealth(int healthChange);
}

Enums are basically named numbers, for example:

enum Months {January=1, February=2 ...}

So now instead of saying if currentMonth == 3 you can say if currentMonth == Months.March
Enums make the code easier to follow.

1

solved What’s the difference between enumerators, structs and classes? [closed]