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 10All lessons in this course
- Raw Pointers and the Address-of Operator
- Dereferencing and Pointer Arithmetic
- nullptr and Null Pointer Safety
- When to Use Pointers vs References