Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Part III: Memory Management > Creating Pointers - Pg. 137

Understanding Pointers and Their Usage 137 HOUR 10 Creating Pointers What You'll Learn in This Hour: . What pointers are . How to declare and use pointers . What the heap is and how to manipulate memory Understanding Pointers and Their Usage One of the most powerful tools available to a C++ programmer is the pointer. Point- ers provide the capability to manipulate computer memory directly. That power comes at a price: Pointers are one of the most difficult aspects of C++ for many begin- ners to learn. A variable is an object that can hold a value. An integer variable holds a number. A character variable holds a letter. A pointer is a variable that holds a memory address. Okay, so what is a memory address? To fully understand this, you must know a little about computer memory. Computer memory is where variable values are stored. By convention, computer memory is divided into sequentially numbered memory locations. Each of these loca- tions is a memory address. Every variable of every type is located at a unique address in memory. Figure 10.1 shows a schematic representation of the storage of an unsigned long integer vari- able, theAge . Different computers number the memory using different complex schemes. Usually, programmers don't need to know the particular address of any given variable because