0Pricing
C++ Academy · Lesson

Raw Pointers and the Address-of Operator

Declare pointers, take addresses with & and understand pointer types.

What is a Pointer?

A pointer holds the address of another object. It is a variable whose value is a memory location.

Declaring a Pointer

The pointer type is T*. Conventionally place the * with the type.

int x = 10;
int* p = &x;          // p holds the address of x
std::cout << p;        // prints an address
std::cout << *p;       // prints 10

All lessons in this course

  1. Raw Pointers and the Address-of Operator
  2. Dereferencing and Pointer Arithmetic
  3. nullptr and Null Pointer Safety
  4. When to Use Pointers vs References
← Back to C++ Academy