Translated by OpenAI
FCTA: Fyvo1d’s C++ Tutorial with Agent — Outline
Organizing principle: by programming language capability domains, not by syntax elements
【0】Prologue: Why C++ ← existing (fcta-00)
- The ten stages of C++ proficiency joke
- Three core ideas set the tone: zero-cost abstraction / full lifecycle control / metaprogramming
- How to use this tutorial
- Environment setup: MacOS / Windows (WSL2) / Linux / VSCode / CMake / Agent
Capability Domain 1: Computation — Make the machine do what you intend
【1】The minimal set for Turing completeness
- Hello World: compilation, execution
- Declaration and assignment: name → value → somewhere in memory
- Expressions and operators: turn values into new values
- Branching: if / switch
- Loops: for / while / do-while
- Hands-on: Guess the Number (using all of the above elements)
Capability Domain 2: Abstraction — Give names to computations
【2】Functions and Recursion
- Why functions are needed: reuse, decomposition, naming
- Declaration and definition: signature = contract
- Parameters and return values: the pipes for data entering and leaving a function
- Call stack intuition
- Recursion: a function calling itself
- Base case + recursive case
- Factorial / Fibonacci / Tower of Hanoi
- Function overloading: same name, different contracts
- 【Best Practice】Short, single responsibility, good names
Capability Domain 3: Data — How values and memory work in C++
【3】Values and Types
- What is a value: a block of memory + a way to interpret it
- The role of the type system: the compiler knows your intent
- Integers and floating-point: precision, range, pitfalls
- auto: let the compiler fill in the type
- const / constexpr: immutability is the default virtue
【4】Memory — Where values live
- Stack and heap: two completely different living experiences
- Object lifetime: when it is born and when it dies
- Value categories (lvalue/rvalue/xvalue): not about memorizing tables, but understanding “can you take its address” and “can you steal from it”
【5】Indirect Access — Pointers and References
- Why indirect access is needed: you don’t want to copy, you want to share, you want to modify elsewhere
- Pointers: store an address +
*dereference - References: aliases, not syntactic sugar for pointers
- Pointers and arrays: legacy but you must know
- The safety philosophy of nullptr
- Using pointers as parameters: truly “modifying external variables”
- 【Best Practice】reference > raw pointer, always check for null
Capability Domain 4: Organization — Bundle data and methods together
【6】Structs and Containers
- struct: a user-defined composite type
- Arrays: contiguous storage,
[]vs std::array vs std::vector - std::string: strings finally not painful to use
- Range-based for loop
- 【Best Practice】std::vector is the default container
【7】Classes and Encapsulation — data + operations = object
- class vs struct: the only difference is default access level
- public/private: the boundary between interface and implementation
- this pointer: who is calling me?
- Construction and destruction: the moments of an object’s birth and death
- 【Best Practice】member variables private, interface public
Capability Domain 5: Resources — Acquire, use, release
【8】RAII — C++’s greatest invention
- Why manual resource management is error-prone
- The core of RAII: construction is acquisition, destruction is release
- Why GC languages are all learning RAII (Python
with/ Java try-with-resources / Godefer) - Hands-on: fstream, lock_guard are all RAII
- 【Best Practice】Resource management = RAII, no exceptions
【9】The Six Special Members — Rule of Five / Rule of Zero
- Copy constructor / copy assignment: the cost of copying
- Destructor: the moment of cleanup
- Move constructor / move assignment: the watershed of C++11
- When the compiler generates them for you and when it doesn’t
- Rule of Zero: let the compiler do the work
- 【Best Practice】Rule of Zero > Rule of Five
【10】Smart Pointers — Let the compiler manage the heap for you
- unique_ptr: exclusive ownership, zero overhead
- shared_ptr / weak_ptr: shared ownership, at a cost
- make_unique / make_shared
- When heap allocation is still necessary
- Memory leak detection: ASan / Valgrind hands-on
- 【Best Practice】Raw new/delete only appear when building wheels
Capability Domain 6: Polymorphism — Same interface, different behavior
【11】Operator Overloading — Make user-defined types behave like built-in types
- Arithmetic / comparison / assignment operators
<=>(three-way comparison, C++20)- The streaming intuition of
<</>> - Conversion operators and explicit
- 【Best Practice】Semantics consistent with built-in types; don’t let
*make network requests
【12】Inheritance and Virtual Functions — Runtime polymorphism
- “is-a” vs “has-a”: inheritance vs composition
- vtable: the cost of runtime polymorphism
- Why virtual destructors must exist
- Pure virtual functions and abstract classes = interfaces
- final / override
- 【Best Practice】Non-leaf classes abstract, leaf classes final
【13】Templates and Concepts — Compile-time polymorphism
- Function templates: the compiler writes overloads for you
- Class templates
- Specialization and partial specialization
- Concepts (C++20): make template errors readable
- Variadic templates
- 【Best Practice】Use Concepts for constraints, not SFINAE showing off
Capability Domain 7: Composition — Use the standard library instead of hand-written code
【14】STL Containers and Algorithms
- Container panorama: sequence / associative / unordered
- Choosing vector / deque / list / map / unordered_map
- Iterators: a unified “traversal” interface
<algorithm>: sorting, searching, transforming- std::string_view / optional / variant
- 【Best Practice】Know Big-O, use algorithms instead of hand-written loops
【15】Lambda — Code as data
- Capture: meaning of
[=]/[&]/[this] - Lambda under the hood is an anonymous class
- Lambda +
<algorithm>: declarative style - 【Best Practice】Short inline, long extract into a function
Capability Domain 8: Engineering — Keep the project under control
【16】Compilation and Build
- The compilation/linking pipeline: what each step does
- Header files and implementation files: ODR (One Definition Rule)
- CMake hands-on
- C++20 Modules
- 【Best Practice】One target, one responsibility
【17】Error Handling
- Exceptions: try/throw/catch
- Exception safety levels
- std::error_code / std::expected (C++23)
- Assertions
- 【Best Practice】Exceptions report bugs, error codes handle expected failures
Capability Domain 9: Concurrency and Performance
【18】Concurrency
- std::thread / std::jthread
- mutex + lock_guard (RAII review!)
- atomic and a first look at memory ordering
- future / promise
- 【Best Practice】Tasks > threads, avoid shared mutable state
【19】Performance Thinking
- Measure before optimizing
- Cache friendliness
- Virtual function overhead and alternatives
- Compile-time optimization (LTO / PGO)
- constexpr and compile-time computation
- 【Best Practice】Algorithmic complexity > micro-optimization > guessing
Capability Domain 10: Looking Ahead
【20】The Past and Future of C++
- C++98 → 11 → 14 → 17 → 20 → 23 → 26
- Which standard should you use
- Idioms and design patterns in C++ form
- C++ vs Rust/Carbon: competition or dialogue
- The irreplaceability of C++ programmers in the Agent era
Appendix
- A. Agent hands-on (link to agentic-programming-00)
- B. End-of-chapter exercises and interview questions
- C. Recommended book list
References
This outline references the organizational structure of the following courses and roadmaps:
- University of Amsterdam — C++ Programming Methods (2024–2025)
- Cornell University — CS 2024: C++ Programming (Fall 2025)
- Johns Hopkins University — Object-Oriented Programming with C++ (Spring 2025)
- Johns Hopkins University — Introduction to Programming Using C++ (Fall 2025)
- University of Genoa — Laboratorio di Programmazione (2024–2025)
- Saylor Academy — CS107: C++ Programming
- GitHub community roadmap — Prince200510/Cpp
- GitHub community roadmap — moclananh/CPP_FromBeginToAdvanceRoadmap
- Coursera — Practical C++: Learn C++ Basics Step by Step
- Coursera — Fundamentals of Object-Oriented Programming: C++