Why user defined types?


at this state of code I do not see code being reduced when we introduced the struct AnimData type and made scarfyData, nebData and neb2Data. This was introduced as one of the reasons why user defined types. Mybe this will happen latter when we introduce some structures of AnimData. Like array or vector.

One of the reasons to introduce new types I have found int the Byorne Stroustrup book. Principles of programming. He says:

Types are good for directly representing ideas in code. When we write code, the
ideal is to represent our ideas directly in our code so that we, our colleagues, and the compiler can understand what we wrote.
Example: When we want to do integer arithmetic, int is a great help.

The help comes in two forms:
• Representation: A type “knows” how to represent the data needed in an object.
• Operations: A type “knows” what operations can be applied to objects.

Many ideas follow this pattern: “something” has data to represent its current value — sometimes called the current state — and a set of operations that can be applied.