Chapter 6. Derived data types
This chapter covers
- Grouping objects into arrays
- Using pointers as opaque types
- Combining objects into structures
- Giving types new names with typedef
All other data types in C are derived from the basic types that we know now. There are four strategies for deriving data types. Two of them are called aggregate data types, because they combine multiple instances of one or several other data types:
- Arrays: These combine items that all have the same base type (section 6.1).
- Structures: These combine items that may have different base types (section 6.3).
The two other strategies to derive data types are more involved:
- Pointers: Entities that refer to an object in memory. Pointers are by far the most involved concept, and we will delay a full discussion of them to chapter 11. Here, in section 6.2, we will only discuss them as opaque data types, without even mentioning the real purpose they fulfill.
- Unions: These overlay items of different base types in the same memory location. Unions require a deeper understanding of C’s memory model and are not of much use in a programmer’s everyday life, so they are only introduced later, in section 12.2.