C++ articles & guides

Short, plain-English explanations with code you can run right on the page. New guides land regularly.

β˜… Modern C++ roadmap (C++11 β†’ C++23)

Start here if you already know the basics: auto, range-for, smart pointers, lambdas, then concepts, ranges and modules β€” with old vs new code for each.

β˜… Seven-lesson beginner course

Variables, decisions, loops, arrays, functions and pointers β€” in order, each with runnable code and matching practice problems.

Recursion, without the mystique

Base cases, the call stack, Tower of Hanoi, and how to turn recursion into a loop.

C++ functions: the full picture

Parameters, return values, scope, and why pass-by-value cannot change the caller.

C++ arrays: the whole picture

Layout, why indices start at 0, sizing, the running-max pattern, and the bugs that never announce themselves.

Big O notation, without the maths

What O(1), O(n), O(nΒ²) and O(log n) mean, with loops that count their own steps.

char[] vs std::string

What a C string really is: the hidden '\0' terminator, why strlen exists, the strcpy overflow, and what std::string fixes.

What is int main() in C++?

The entry point every program needs: both standard signatures, what the return value does (run one that exits with 42), and why void main() is a trap.

C++ for vs while loop

Which loop when β€” with a cin sentinel demo, break/continue, the semicolon-after-header trap, and a runnable FizzBuzz.

The while loop explained

Condition, body, update: countdowns, digit-chewing, sentinel reads and while (cin >> x) β€” plus the anatomy of an infinite loop.

Data types: int, double, char, bool

What each type stores and how each one breaks β€” overflow, float fuzz, 'a' vs "a", bools printing as 1/0 β€” with the char-arithmetic tricks interviews love.

C++ comments done right

// vs /* */, the no-nesting trap, why commented-out code rots β€” and the why-not-what rule that separates useful comments from noise.

Why 7 / 2 equals 3

Integer division truncates, it doesn't round. The rule, %, casts in the right order, negative-number behavior, and the three bugs this causes.

++i vs i++

Both add one β€” but which value does the expression give back? See it run, learn when it costs a copy, and the famous two-increments undefined-behavior trap.

Pass by value vs pointer vs reference

Copies vs addresses: watch a function fail to modify its argument, the swap classic, why arrays always decay, and the decision rules for each.

cin >> vs getline()

Why your string input comes up empty: the leftover-Enter trap, reproduced in runnable code, plus the one-line fix and the mental model that prevents it.

10 common compiler errors, decoded

A field guide to expected ';', was not declared in this scope, linker undefined reference and friends β€” what each means and the fix.

C++ vector vs array

C-style array vs std::array vs std::vector: the differences that matter, the "just use vector" rule of thumb, and the interview follow-ups.

Stack vs heap

Where your variables actually live: watch local vs global lifetime run in real code, then new/delete, RAII, and the two famous failure modes.

struct vs class

The only real difference is one default (public vs private) β€” the exact rule, the convention real codebases follow, and the inheritance-default follow-up.

Compile & run C++ on Windows / Mac / Linux

Free setups in 10 minutes per system, the g++ commands worth adopting, what "compile β†’ link" actually means, and the setup errors everyone hits.

15 C++ interview questions for beginners

Pointers vs references, pass-by-value, const, stack vs heap β€” short answers you can say out loud, with runnable examples.

Just starting?

Begin with the Hello World lesson, line by line, then experiment in the playground β€” no install, no account, everything runs in your browser.