Simple Vs Structured Data Types
- As we have seen, simple data types hold only one value per instance.
- They can not reasonably be broken down any further.
- A structured data type is a collection of data.
- It is made up of one or more simple data types.
- The string is an example of a structured data type
- A collection of characters
- As well as an integer size.
- A stream is also a structured data type.
- It has a "pointer" into the file, ie where the next read/write will occur
- It has a collection of flags that describe the state of the stream.
- In the documentation this is described as a set of bits.
- Note file.eof reference
- "Note that the value returned by this function depends on the last operation performed on the stream (and not on the next)."
- EOF is only true AFTER an attempt to read past the end of the file, not before.
- It is a test like, fail or bad, not a predictor.
- In order to progress to build larger and more complex problems we need to learn how to create more complex data types.
- These include
- Structures struct
- Arrays
- Classes class
- Unions union
- We also have two more simple types
- Pointers - a way to access memory in a different way
- References - the way you pass parameters, and other things.