C++ for Beginners
From your first program to classes, smart pointers, templates and a final project.
Tests check every exercise: in your browser and in the cloud
Exercises are compiled and checked on the site, so you need nothing installed to take the course.
Install Visual Studio Community
To write code on your own computer, download Visual Studio Community for free and choose «Desktop development with C++» in the installer.
Syllabus
- Arithmetic: integer division, remainder, overflowTheory
- Quiz — 7 / 2 and −7 % 3Quiz
- Comparisons, logic, ++ and --Theory
- Quiz — whether the function is calledQuiz
- Bitwise operators, ternary and precedenceTheory
- Quiz — operator precedenceQuiz
- Exercise: digit sum of a three-digit numberExercise
- Exercise: bit flagsExercise
- Declaration and definitionTheory
- Parameters: by value and by referenceTheory
- Quiz — copy or referenceQuiz
- Const referencesTheory
- Quiz — a reference to a local variableQuiz
- Exercise: swap two valuesExercise
- Function overloadingTheory
- Quiz — which overload the compiler picksQuiz
- Default argumentsTheory
- Exercise: shape areasExercise
- Lambdas: a first lookTheory
- Quiz — what the lambda capturesQuiz
- Exercise: GCD and LCMExercise
- References, lvalues and rvaluesTheory
- Pointers, addresses and nullptrTheory
- Quiz — reference or pointerQuiz
- Quiz — a function returning a pointerQuiz
- A pointer to numbers in a rowTheory
- const T* and T* constTheory
- Quiz — what is const hereQuiz
- Exercise: min and max through referencesExercise
- Exercise: find an element, return a pointerExercise
- std::vectorTheory
- Quiz — size and capacityQuiz
- map, set and unordered_mapTheory
- Quiz — operator[] on a mapQuiz
- IteratorsTheory
- Quiz — an iterator after push_backQuiz
- Quiz — erasing in a loopQuiz
- Choosing a containerTheory
- Exercise: remove duplicatesExercise
- Exercise: word frequenciesExercise
- Exercise: transpose a matrixExercise
- Complexity: O(1), O(n), O(n log n)Theory
- Quiz — which complexityQuiz
- sort, find, count, accumulate and lambdasTheory
- Quiz — a comparator for sortQuiz
- Binary search and recursionTheory
- Quiz — the base case of recursionQuiz
- Exercise: binary searchExercise
- Exercise: sort by keyExercise
- Exercise: fast exponentiationExercise
- struct, class and accessTheory
- Constructors and the member initializer listTheory
- Quiz — field initialization orderQuiz
- Destructor and the rule of zeroTheory
- const methodsTheory
- Quiz — a const methodQuiz
- Exercise: bank accountExercise
- Exercise: IntStack classExercise
- InheritanceTheory
- virtual, override and polymorphismTheory
- Quiz — a derived object by valueQuiz
- Quiz — what override checksQuiz
- Abstract classes and dynamic_castTheory
- Quiz — dynamic_castQuiz
- Exercise: shapes with a virtual areaExercise
- Stack and heap; new and deleteTheory
- Quiz — using an object after deleteQuiz
- Quiz — virtual destructorQuiz
- RAIITheory
- Quiz — new and an early returnQuiz
- std::unique_ptr and std::moveTheory
- Quiz — unique_ptrQuiz
- std::shared_ptr and weak_ptrTheory
- Quiz — shared_ptrQuiz
- Exercise: ScopeGuardExercise
- Exercise: owning buffer on unique_ptrExercise
- Exercise: playlist of shared songsExercise
- Function templatesTheory
- Template argument deductionTheory
- Quiz — argument deductionQuiz
- Exercise: generic maxExercise
- Class templates and specializationTheory
- Quiz — templatesQuiz
- Quiz — which specialization is chosenQuiz
- Exercise: Pair templateExercise
- Variadic templatesTheory
- Quiz — sizeof...Quiz
- Exercise: a running sumExercise
- Threads: why and howTheory
- Quiz — a forgotten joinQuiz
- Data races, mutexes and lock_guardTheory
- Quiz — what is wrong with ++counterQuiz
- Quiz — where the mutex is releasedQuiz
- Deadlock and scoped_lockTheory
- Quiz — two mutexes in opposite orderQuiz
- std::atomicTheory
- async and futureTheory
- Quiz — when std::async runsQuiz
- Durations: chronoTheory
- Exercise: countdown timerExercise