What Is a Variable?

From a programmer's point of view, a variable is a location in your computer's memory in which you can store a value and from which you can later retrieve that value.

To understand this, you must first understand a bit about how computer memory works. Your computer's memory can be thought of as a series of cubby holes, all lined up in a long row. Each cubby hole—or memory location—is numbered sequentially. These numbers are known as memory addresses.

Variables not only have addresses, they have names. For example, you might create a variable named myAge. Your variable is a label on one of these cubby holes so that you can find ...

Get Sams Teach Yourself C++ in 24 Hours, Third 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.