Category

Pointers

Memory addresses, pointer syntax, null pointers, array decay, pointer arithmetic, const-correctness, and common pointer lifetime errors.

Memory Addresses and Pointers

Any object in memory that is active when your program is running has a location, called its address. You can use C++ to get the address of an object and have yo…

Jul 14, 2026 →

Address-of and Dereference Operators

Let's discuss the two operators we have that use addresses, them being & and *. One of them finds the address of something and the other reads the thing at the…

Jul 14, 2026 →

Null Pointers and nullptr

A pointer can contain an address, but there is not always an object for it to point to. In this case, the pointer needs to be assigned a special value that says…

Jul 14, 2026 →

Passing Pointers to Functions

When a function wants to access an existing object in the caller, one clear way is to pass the address of the object. The function setToZero takes a pointer cal…

Jul 14, 2026 →

Pointers and Arrays

An array name and a pointer to its first element can be used in almost the same way. That is part of the language. We've declared an array scores of 4 integers.…

Jul 14, 2026 →

Passing Arrays to Functions and Understanding Array Decay

Something subtle but important happens when an array is passed to a function: the array decays to a pointer to its first element. This process is called array d…

Jul 14, 2026 →

Pointer Arithmetic

Pointer arithmetic means adding an integer to a pointer, which moves the pointer that number of element sizes forward. An array of ints named values is declared…

Jul 14, 2026 →

Const Pointers and Pointers to Const

A const qualifier can appear in two different locations relative to the * in a pointer declaration. These two locations have completely different semantics. Dec…

Jul 14, 2026 →

const_cast and Const-Correctness

Const correct code is where objects that are not intended to be modified are marked as const, and the compiler then enforces that "promise." An old interface or…

Jul 21, 2026 →
About CppLearn

CppLearn is an interactive, free reference for modern C++. In each lesson, you'll find out how the language works, rather than just lines of code that you can copy and paste. We cover concepts starting from beginner lessons on fundamentals and proceed to templates, move semantics, smart pointers, and areas that usually trap or scare C++ learners.