Chapter 10
- We are starting chapter 10.
- you should read it.
- That is not a suggestion.
- The chapter begins by reviewing the different data types you know.
-
-
- A simple or atomic data type is a datatype where each value is atomic or indivisible
- floats and ints are examples of this.
- A structured data type is a data type where each value is a collection of components whose organization is characterized by the method used to access individual components.
- Strings are an example of this.
- The components are the different letters.
- .at() or [] can be used to access these individual letters.
- When discussing data types, we frequently discuss
- The domain or the set of values the data type can hold
- The operations or the things you can do to a data type.
- Consider the type bool
- The domain is true and false.
- The operations are
- Boolean operators (and, not, or)
- Comparison
- Consider the integers
- The domain is INT_MIN to INT_MAX
- Look at /usr/incude/limits.h
- The operations are
- +,-,*,/
- Comparison
- input and output
- Characters are strange
- The domain is CHAR_MIN to CHAR_MAX
- Operations are the same as the integer.
- But they have a different internal representation from their external representation.
- Internal representation is how they are stored (ascii value)
- External representation is how it is presented externally (cout, ...)
- C++ allows us to create user defined data types.
- Typedef
- Not really a user defined type, just giving a nickname to an existing type.
- Syntax:
typedef old_type new_type
- Example:
typedef unsigned long long int BigNumT
- typedef allows us to
- Rename a difficult type name (unsigned long long int) to something easier to remember.
- Establish abstractions
-
size_type
- See this reference or page 467 of your book.
- This means a properly written program can experience a change in the size of string provided by the a different compiler with just a recompile.
- See fact.cpp