O'Reilly logo

Beginning Programming with C++ For Dummies® by Nat Coalson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 17. Pointing the Way to C++ Pointers

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.

Warning

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.

What's a Pointer?

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.

Warning

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required