In This Chapter
Introducing the concept of pointer variables
Declaring and initializing a pointer
Using pointers to pass arguments by reference
Allocating variable-sized arrays from the heap
This chapter introduces the powerful concept of pointers. By that I don't mean specially trained dogs that point at birds but rather variables that point at other variables in memory. I start with an explanation of computer addressing before getting into the details of declaring and using pointer variables. This chapter wraps up with a discussion of something known as the heap and how we can use it to solve a problem that I slyly introduced in the last chapter.
But don't think the fun is over when this chapter ends. The next chapter takes the concept of pointers one step further. In fact, in one way or another, pointers will reappear in almost every remaining chapter of this book.
It may take you a while before you get comfortable with the concept of pointer variables. Don't get discouraged. You may have to read through this chapter and the next a few times before you grasp all of the subtleties.
A pointer is a 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 ...