C++
44 articles in this topic

C++ Encapsulation and Class Invariants: Build Objects That Stay Valid
Learn to design a C++ BankAccount that cannot be created or changed into an invalid state. Trace constructor checks, guarded operations, representation leaks, and boundary tests.

C++ deque, list and forward_list: Choose the Right Non-Vector Container
Use one controlled sequence-editing workload to compare deque, list and forward_list. See where search cost, iterator validity and memory locality change the decision.

C++ Composition vs Inheritance: Choose the Stable Relationship
Follow one C++ notification design from eight combination subclasses to three replaceable policies. The worked trace shows exactly where inheritance still fits.

C++ Lambda Expressions: Capture Rules, Closures and STL Patterns
Learn to read C++ lambdas, trace copied and referenced state, write a valid sort comparator, and prevent dangling-reference bugs in stored callbacks.

C++ Fundamental Types and Conversions: Predict Values from the Bits
Learn a repeatable way to predict C++ expression types and values by tracing representations, promotions, common types, and final storage conversions.

C++ Function Overloading and Default Arguments: Resolve Valid and Ambiguous Calls
Learn why default arguments affect viability but not ranking, then resolve five score calls using exact matches, promotions and conversions. Includes ambiguity repairs and call-time default evaluation.

C++ Exception Handling: Typed Errors, Stack Unwinding and Safe Recovery
Build a small C++ parser that reports machine-readable failures, recovers only from a malformed optional field, and preserves saved state when a required field fails.

C++ enum class, struct, pair and tuple: How to Model Small Data Safely
Model Ticket 417 three ways, calculate the same response window, then add an owner to see why named fields often beat positional access in changing code.

C++ const, constexpr and consteval: Runtime Immutability vs Compile-Time Guarantees
See exactly what each C++ keyword guarantees. One C++20 program separates immutability, optional constant evaluation and mandatory constant evaluation.

C++ Compiler Warnings and Sanitizers: Catch Bugs Early
Build a practical C++ safety net with strict warnings and sanitizer runs. Three small programs show how to find, explain and fix defects before they spread.

C++ Arrays vs std::array vs std::span: Choose the Right Interface
Run the same five integers through raw-array, std::array and std::span interfaces, then choose from their ownership, size and lifetime contracts.

C++ Classes and Objects MCQs: 11 Solved Questions on Members, Pointers and Inheritance
Work through 11 C++ classes and objects MCQs, then use the fresh explanations and fixed examples to repair mistakes in access, lifetime and inheritance rules.