C++ By Example 三 精彩文摘
Memory Addressing,Binary, and Hexadecimal Review
You do not have to understand the concepts in this appendix to become well-versed in C++. You can master C++, however, only if you spend some time learning about the behind-the-scenes roles played by binary numbers. The material presented here is not difficult, but many programmers do not take the time to study it; hence, there are a handful of C++ masters who learn this material and understand how C++ works “under the hood,” and there are those who will never master the language as they could.
You should take the time to learn about addressing, binary numbers, and hexadecimal numbers. These fundamental principles are presented here for you to learn, and although a working knowl-edge of C++ is possible without knowing them, they greatly enhance your C++ skills (and your skills in every other programming lan-guage).
Appendix A o Memory Addressing, Binary, and Hexadecimal Review
After reading this appendix, you will better understand why different C++ data types hold different ranges of numbers. You also will see the importance of being able to represent hexadecimalnumbers in C++, and you will better understand C++ array and pointer addressing.
Each memory location inside your computer holds a single character called a byte. A byte is any character, whether it is a letter of the alphabet, a numeric digit, or a special character such as a period, question mark, or even a space (a blank character). If your computer contains 640K of memory, it can hold a total of approxi-mately 640,000 bytes of memory. This means that as soon as you fill your computer’s memory with 640K, there is no room for an addi-tional character unless you overwrite something.
Before describing the physical layout of your computer’s memory, it is best to take a detour and explain exactly what 640K means.