Pointers and addresses

Author

Clayton Cafiero

Published

2025-01-05

An introduction to memory addresses and pointers in C++. We show how memory is allocated, how addresses are referenced, and how to create and dereference a pointer.

Resources

Additional reading (optional)

Comprehension check:

Consider the following code:

double pi = 3.14159;
double* whatIsThis = π
  1. Describe the value of the variable whatIsThis.
  2. What will this print? std::cout << *whatIsThis << std::endl;.
  3. What symbol is used for the “address of” unary operator?
  4. True or false? The size of a pointer to a bool is smaller than the size of a pointer to a float.
  5. True or false? We call the process of getting the address of a variable “dereferencing”.

Answers: ǝslɐɟ / ǝslɐɟ / ⅋ / 6ϛƖㄣƖ˙Ɛ / ᴉd ǝlqɐᴉɹɐʌ ǝɥʇ ɟo ssǝɹppɐ ǝɥʇ sploɥ ʇI

Copyright © 2023–2025 Clayton Cafiero

No generative AI was used in producing this material. This was written the old-fashioned way.