01 · Fundamentals of C++
The foundations: variables, primitive data types, arithmetic-logical operators and input/output management with std::cout and std::cin.
- std::cout / std::cin
- int / double / bool
- auto & const
- % / == / !=
End of the C++ Course
Congratulations! You have completed all 10 modules and 26 lessons of the C++ course — from types, pointers, OOP, and virtual polymorphism to RAII smart pointers, templates, move semantics, STL/ranges, std::optional, exceptions, and std::jthread concurrency.
10 modules · 26 lessons · 130 checkpoints
C++ exercises are verified locally in the browser using Tree-sitter AST parsing (`tree-sitter-cpp.wasm`) plus structural and keyword checks; to compile and execute real C++20 code, click Open on Compiler Explorer (godbolt.org).
The foundations: variables, primitive data types, arithmetic-logical operators and input/output management with std::cout and std::cin.
Conditional expressions for making decisions and iterative loops for repeating instructions.
Break down the code into reusable blocks and understand how C++ passes data into memory.
Introduce classes, encapsulation, and automatic resource management.
Manage data collections and understand how physical memory works with pointers.
Extend existing classes and implement polymorphic behavior via virtual functions and inheritance.
Modern and secure dynamic memory management without leaks thanks to intelligent standard library pointers.
Introduce generic programming by writing reusable functions and classes that are independent of data types.
Zero out useless copies with rvalue references (&&), express inline logic with lambda and compose pipeline STL / C++20 ranges.
Model absence and errors at the type level (optional, variant, exceptions RAII) and write multithreaded code without data races.
Bring Modern C++ idioms together across five progressive stages: isEven predicate, in-place mutation via int&, encapsulated Counter class, functional STL + lambda sumPositive, and move-only RAII wrapper SafeHandle.
Implement `bool isEven(int n)` applying arithmetic modulo `%` and a clean boolean return expression (Module 1 + Module 2).
Define bool isEven(int n) returning true when n is even and false otherwise.
Write return n % 2 == 0; directly without redundant if/else branches.
Solution available after 3 attempts
Modify the caller variable directly through an lvalue reference `int&` without raw pointer syntax (Module 3).
Define void squareByRef(int& n) that squares n in-place.
Write n = n * n; (or n *= n;) inside the body of squareByRef.
Solution available after 3 attempts
Combine private member `int count`, member initializer list `Counter() : count(0) {}`, and public methods (Module 4).
Complete class Counter with private int count, constructor Counter() : count(0) {}, void increment(), and int getCount().
Add Counter() : count(0) {}, void increment() { count++; }, and int getCount() { return count; }.
Solution available after 3 attempts
Selectively sum positive integers from `const std::vector<int>&` by passing a lambda closure into `std::accumulate` (Module 5 + Module 9).
Implement int sumPositive(const std::vector<int>& nums) using std::accumulate with a lambda [](int acc, int x) summing only values where x > 0.
Return std::accumulate(nums.begin(), nums.end(), 0, [](int acc, int x) { return x > 0 ? acc + x : acc; });.
Solution available after 3 attempts
Unite exclusive ownership `std::unique_ptr<int>`, deleted copy, defaulted move, and safe `std::optional<int>` access (Module 7 + Module 9 + Module 10).
Complete class SafeHandle with std::unique_ptr<int> ptr, explicit SafeHandle(int value) using std::make_unique<int>(value), deleted copy (= delete), defaulted move (= default), and std::optional<int> read() const returning std::nullopt when empty.
Check if (!ptr) return std::nullopt; return *ptr; inside read(), delete copy with SafeHandle(const SafeHandle&) = delete;, and keep SafeHandle(SafeHandle&&) = default;.
Solution available after 3 attempts
Complete quick reference covering basics, pointers, OOP, smart pointers, templates, move semantics, STL ranges, and std::jthread concurrency.
Consolidate your C++20 skills locally with strict warnings (`-Wall -Wextra -std=c++20`) or experiment with pointer, move, and RAII scenarios inside the interactive Playground.