C++

44 articles in this topic

C++ Object Lifetime and Storage Duration: Trace Construction, Destruction, and Dangling State

Learn to separate scope, storage duration, lifetime, and ownership. Trace seven objects precisely, then repair dangling pointers, references, and views.

Updated 19 Oct 20265 min readC++

C++ Diamond Problem: Ambiguity, Duplicate State and Virtual Inheritance

See why a C++ diamond duplicates base state, how virtual inheritance shares it, and when qualification, interfaces, or composition is the clearer design.

Updated 15 Oct 20265 min readC++

C++ Abstract Classes and Interfaces: Build a Usable Storage Contract

Build a C++17 ScoreStore interface, swap vector and hash-backed implementations behind it, and verify both with the same runnable contract test.

Updated 11 Oct 20265 min readC++

C++ Virtual Functions and Polymorphism: Trace Dynamic Dispatch Step by Step

Trace a Shape hierarchy line by line to see how static type, dynamic type, final overriders, object slicing, and virtual destructors determine C++ output.

Updated 7 Oct 20265 min readC++

C++ unordered_map and unordered_set: Hashing, Equality and a Custom-Key Frequency Counter

Build a correct mental model for C++ unordered containers, then trace a custom-key counter through a real collision without merging distinct keys.

Updated 2 Oct 20266 min readC++

C++ STL Containers: Choose by Access Pattern, Mutation Cost and Ownership

Choose a C++ STL container from the workload, not from habit. Trace sequence operations, keyed counts, invalidation and object lifetime through exact examples.

Updated 27 Sep 20266 min readC++

C++ STL Algorithms: Sort, Search, Transform and Clean Data in One Pipeline

Trace nine sensor readings through sort, lower_bound, transform, erase-remove and accumulate, with every iterator rule and intermediate value explained.

Updated 25 Sep 20266 min readC++

C++ std::vector Internals: Growth, Capacity, Reallocation and Iterator Invalidation

Learn how std::vector manages contiguous storage, why an append can relocate every element, and which iterators, pointers and references survive each mutation.

Updated 24 Sep 20266 min readC++

C++ std::string_view: Fast Read-Only Text APIs Without Accidental Copies

Learn when a read-only text API should take std::string_view, then trace one request parser and spot the lifetime errors that make views dangle.

Updated 22 Sep 20266 min readC++

C++ stack, queue and priority_queue: Adapter Behaviour with Traced Examples

Trace the same values through std::stack, std::queue and std::priority_queue, then learn comparator tie-breaking, operation costs and safe pop patterns.

Updated 21 Sep 20266 min readC++

C++ set and map: Ordered Containers, Custom Keys and Bounds

See how one comparator controls traversal, uniqueness and bounds in C++ ordered containers. Two student examples make rejected inserts and map updates concrete.

Updated 20 Sep 20266 min readC++

C++ Iterators and Invalidation: Container Rules and Safe Erase Loops

Learn to read iterator ranges, match algorithms to categories, and mutate standard containers without using stale handles. Includes two fully traced erase examples.

Updated 18 Sep 20266 min readC++