|
|
|
|
|
|
|
BACKGROUND INFORMATION Data Storage |
|
|
|
| |
|
|
|
|
Where does a program get the data it needs to operate? Data is stored in the computer's memory. Remember that memory is divided into a large number of separate locations or cells, each of which can hold a piece of data. Each memory location has a unique address that we refer to when we store or retrieve data. We can visualize memory as a set of post office boxes, with the box numbers as the addresses used to designate particular locations. |
|
|
|
| | |
|
|
|
|
Of course, the actual address of each location in memory is a binary number in a machine language code. In C++ we use identifiers to name memory locations, then the compiler translates them for us. This is one of the advantages of a high-level programming language: It frees us from having to keep track of the actual memory locations in which our data and instructions are stored. |
|
|
|
|
|
|
|
|
|
The data types char, short, int, and long are known as integral types because they refer to integer valueswhole numbers with no fractional part. (We postpone talking about the fifth integral typeenumuntil Chapter 10.) |
|
|
|
|
|
|
|
|
In C++ the simplest form of integer value is a sequence of one or more digits: |
|
|
|
|
|