Enumeration and structure are completely different concepts that fulfill different goals.
An enum allows you to declare a series of identifiers for use in your code. The compiler replaces them with numbers for you. This is often useful in order to make your code more readable and maintainable, because you can use descriptive names without performance limitation to compare strings. It can also make the code less error prone, because you donโt need to constantly write on certain numbers, which may go wrong if the number changes.
A struct is a data structure. In its simplest case, it contains zero or more pieces of data (variables or objects) grouped together so that they can be stored, processed or transmitted as a whole. You can usually have multiple copies (or instances). However, the structure can be much more complicated. This is actually exactly the same as a class, except that members are public by default and not private. Like a class, a structure can have member functions and template parameters, etc.
One of the significant differences between structures and enumerations is that an enumeration does not exist at run time. This is only for your benefit when you read / write code. However, instances of structures (and classes) can certainly exist in memory at run time.
From an encoding point of view, each identifier in an enumeration does not have its own type. Each member within the structure must have a type.
Peter Bloomfield
source share