Home Page

Learning C++ Pointers for REAL Dummies



Hello and welcome to "Learning C++ Pointers for REAL Dummies." This website was created by Paul DiLorenzo to fill the void of an easy understanding learning module for pointers.

Here are some rave reviews from people around the world:

  • "GOOD JOB with learning C++ pointers for dummies. Because of you I hope to get a 10 (that means A) at programming." Dan
  • "Sir, your tutorial on pointers is a masterpiece, I think you should continue writing more topics on C++." Mayur Jethwa

Pointers are a very difficult and troublesome area for most C++ programmers, beginners and intermediate alike. Most questions pop up about their use and why we even need them. I hope this website helps answer these questions for you and demystify the C++ pointer.

To understand pointers we have to understand how variables are stored. Variables are stored in memory cells inside the computer's memory. The computer's memory is made up of consecutive memory cells, a byte long, each with a unique address.

But we are not going to think in those terms. We are going to believe that computer memory is made up of a bunch of houses on one very long street. Thus, each house is a memory cell. Now, there must be a way for us to find this house. Well, in each house someone lives there. This person of course has a name and this will be our variable identifier. For example:

int paul;

This will put paul into a vacant house, of size int, somewhere along the street. We do not decide where paul will live. This is done by the operating system and the compiler at runtime. In a later section, we will discuss how to get paul to tell us where his house is.

Currently, paul does not have anything stored in his house. But, we all know that wouldn't be any fun to not store anything. So, each house can of course store a value. Continuing from above:

paul = 25;

This will store the value 25 into paul's house.

One last thing before we move into other topics. Let us remember that paul's house is a unique number in memory. In addition, if paul's house was numbered 1234 we know that his house is between houses 1233 and 1235. This is a very important concept for later sections.

This learning module is broken up into seven parts:

  1. Where do you live ( & ) - Explains what the address operator (&) is and how it is used
  2. What you got in your house (*) - Explains that the reference operator (*) is and how it is used
  3. Don't point, it's rude! - Explains how to declare variables that are pointers
  4. I am pointing here! Where are you pointing? - Explains how to initialize a pointer
  5. How do I point to the neighbor? - Explains how to move a pointer from one house to the next
  6. You guys are brothers? - Explains the relationship between arrays and pointers
  7. Beam me up Scotty, multiple times!!! - Explains how pointers can point to other pointers

I would recommend starting at "Where do you live?" and moving from there. But you can also skip to a part that you need help with and learn from there. Have fun!!!

Where do you live? (&)
What you got in your house? (*)
Don't point, it's rude!
I am pointing here!
Where are you pointing?
How do I point to the neighbor?
You guys are brothers?
Beam me up Scotty, multiple times!!!
Quiz for REAL Dummies