C++ - Memory Address

Overview

Estimated time: 20–30 minutes

Inspect the memory address of variables and understand & (address-of).

Learning Objectives

  • Use & to obtain addresses and print pointer values.

Example

int x=5; int* px=&x; // pointer to x

Common Pitfalls

  • Printing pointers with std::cout shows addresses; dereference to print the value.