What’s a Pointer in C++? - dummies

By Stephen R. Davis

A pointer is a C++ variable that contains the address of another variable in the computer’s internal memory. Before you can get a handle on that statement, you need to understand how computers address memory.

The details of computer addressing on the Intel processor in your PC or Macintosh are quite complicated and much more involved than you need to worry about.

Every piece of random-access memory (RAM) has its own, unique address. For most computers, including Macintoshes and PCs, the smallest addressable piece of memory is a byte.

A byte is 8 bits and corresponds to a variable of type char. An address in memory is exactly like an address of a house, or would be if the following conditions were true:

  • Every house is numbered in order.

  • There are no skipped or duplicated numbers.

  • The entire city consists of one long street.

So, for example, the address of a particular byte of memory might be 0x1000. The next byte after that would have an address of 0x1001. The byte before would be at 0x0FFF.

By convention, memory addresses are always expressed in hexadecimal. Maybe it’s so that non-programmers will think that computer addressing is really complicated.