1. Meet C++ and the compiler
BeginnerLearn how a C++ program is structured, compiled, and run, then begin using standard console input and output.
Source code and main()
A C++ program starts from main() in a hosted application.
Compile, run, and read diagnostics
Compilation turns source code into a program and reports many mistakes before execution.
Console input and output
The standard streams provide a convenient way to read and display values.
Module checkpoint: Try it: create a program that asks for a name and a whole number, validates the numeric input, and prints a personalized message.
2. Types, variables, and expressions
BeginnerRepresent data with appropriate types, initialize variables deliberately, and understand operators and conversions.
Variables and initialization
A variable names an object whose type determines the values and operations it supports.
const and type conversions
Const-qualified objects cannot be modified through their declared name, and conversions can change representation or value.
Operators and expressions
Operators combine values to produce new values or comparisons.
Module checkpoint: Try it: calculate a bill total, tax, and per-person split. Decide where integer and floating-point types are appropriate and state any rounding rule.
3. Decisions and loops
BeginnerControl which code runs and repeat operations with conditions that have clear bounds and exit paths.
Conditions and branches
if and else choose which block executes based on a Boolean condition.
Count with for and range-based for
A for loop is useful when iteration has a clear initialization, condition, and update.
while, break, and continue
while repeats while a condition remains true; break and continue alter loop flow.
Module checkpoint: Try it: write a menu-driven program that repeats until the user selects Exit. Test invalid menu choices and the first and last loop iterations.
4. Functions, parameters, and scope
BeginnerOrganize programs into reusable functions, pass information safely, and understand overloads and variable scope.
Function declarations and definitions
A function names a reusable operation with a return type and parameter list.
Pass by value and by reference
Parameter choice controls whether a function receives a copy or access to an existing object.
Overloading, defaults, and scope
C++ allows functions to share a name when their parameter lists distinguish them.
Module checkpoint: Try it: design functions to validate a score, calculate an average, and format a summary. Document each function's inputs, outputs, and any side effects.
5. Arrays, strings, and sequences
BeginnerRepresent collections and text using standard C++ types that make ownership and size easier to manage.
Fixed-size arrays with std::array
std::array stores a fixed number of elements and knows its size.
Text with std::string
std::string manages a sequence of characters and provides common text operations.
Resizable sequences with std::vector
std::vector is the usual default for a sequence whose size may change at runtime.
Module checkpoint: Try it: read several numbers into a vector, compute the minimum, maximum, and average, and handle the case where no numbers were entered.
6. Classes and object-oriented programming
IntermediateBundle state with behavior, enforce class invariants, and use inheritance and polymorphism when they clarify a design.
Classes and encapsulation
A class defines a type and controls how its state can be accessed.
Constructors and const member functions
Constructors establish an object's initial valid state.
Inheritance and virtual functions
Inheritance models an is-a relationship, while virtual functions enable runtime dispatch through a base interface.
Module checkpoint: Try it: implement a BankAccount class with a constructor, a balance query, deposit and withdraw operations, and validation that prevents invalid balances.
7. Pointers, lifetime, and resource management
IntermediateUnderstand object lifetime and use modern C++ ownership patterns to avoid leaks, dangling pointers, and double deletion.
Pointers and references
Pointers represent addresses, while references provide another name for an existing object.
Object lifetime and RAII
RAII ties a resource's lifetime to an object's lifetime so cleanup happens automatically.
unique_ptr and shared_ptr
Smart pointers express ownership and automate deletion of dynamically allocated objects.
Module checkpoint: Try it: review a small program with new and delete, then refactor ownership to standard containers or smart pointers. Explain who owns every resource and how long it lives.
8. The standard library: containers and algorithms
IntermediateUse associative containers, iterators, algorithms, and lambdas to express common data-processing tasks clearly.
Maps, sets, and container choice
Associative containers organize values by keys or uniqueness rules.
Iterators and traversal
Iterators provide a common way to refer to elements in many standard containers.
Algorithms and lambda expressions
Standard algorithms and lambdas let you describe what should happen without writing every loop yourself.
Module checkpoint: Try it: build a word-frequency counter using a map, then display the most useful summaries and explain why you chose that container.
9. Exceptions, validation, and file handling
IntermediateHandle invalid input and operational failures explicitly, and read or write files using standard C++ streams.
Exceptions and error paths
Exceptions report failures that prevent an operation from completing normally.
Read and write files
File streams connect C++ input and output operations to files.
Validate and parse external input
External input should be checked before it is trusted by the rest of a program.
Module checkpoint: Try it: implement a program that loads records from a text file, detects missing or malformed data, and reports a useful error instead of silently using invalid values.
10. Templates and modern C++ features
AdvancedWrite reusable generic code and use modern language features that improve safety, clarity, and performance.
Function and class templates
Templates let the compiler generate code for types that satisfy the operations the template uses.
Copying, moving, and value categories
Move operations can transfer resources from temporary or expiring objects instead of duplicating them.
optional, variant, and structured bindings
Modern library utilities make absence and alternative types explicit in program interfaces.
Module checkpoint: Try it: write a reusable template for finding the maximum value in a compatible sequence, then use std::optional to represent a search that may find nothing.
11. Project structure, testing, and debugging
AdvancedOrganize multi-file programs, build with useful diagnostics, and test correctness including boundary and failure cases.
Headers, source files, and namespaces
A well-organized C++ project separates public interfaces from implementation details.
Build commands and compiler warnings
A repeatable build command helps catch issues consistently across a project.
Testing and debugging systematically
Focused tests and deliberate debugging make failures easier to reproduce and fix.
Module checkpoint: Try it: split a small program into a header, implementation file, and main file. Add tests for normal and boundary behavior, then compile with warnings enabled.
12. Concurrency fundamentals
AdvancedUnderstand basic multithreading tools and shared-state risks, and learn when concurrency adds complexity rather than value.
Starting and joining threads
A thread allows a program to execute work concurrently with other threads.
Mutexes and shared data
A mutex can ensure only one thread at a time accesses a protected critical section.
Tasks, futures, and concurrency design
Higher-level task tools can make results and synchronization more explicit.
Module checkpoint: Try it: create two independent computations, collect their results, and explain why the work is safe to run concurrently. Then identify what synchronization would be required if they shared mutable state.