Chapter 8

Referring to Your Data Through Pointers

IN THIS CHAPTER

check Using two types of memory: the stack and the heap

check Accessing variable addresses through pointers

check Creating variables on the heap by using the new keyword

check Taking pointers as parameters and returning pointers

Where do you live? Don’t say it out loud, because thousands of people are reading this book and you don’t want them all to know. So just think about your address. Most places have some sort of address so that the mail service knows where to deliver your packages and the cable guy can show up sometime between now and 5:00 next Thursday. (So make sure that you’re there.)

Other things have addresses, too. For example, a big corporation in an office building likely has all its cubes numbered. Offices in buildings usually have numbers, and apartments normally have numbers, too.

Now suppose that someone named Sam works in office number 180. Last week, however, Sam got booted out the door for spending too much time surfing the web. Now Sally gets first dibs on office number 180, even though she’s not taking over Sam’s ...

Get C++ All-in-One For Dummies, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.