Introduction to C++
C++ is a fast, compiled language that combines C's direct control over the machine with powerful tools for building large programs: classes, templates, a rich standard library and automatic resource management. It runs game engines, browsers, databases, trading systems and much of the software where performance matters most.
Where C++ is used
- Games and graphics — Unreal Engine and most AAA game engines, 3D tools, VR.
- Browsers and operating system components — Chrome, Firefox and large parts of Windows and macOS.
- Infrastructure — databases such as MySQL and MongoDB, compilers (LLVM), and high-performance servers.
- Finance and science — low-latency trading, simulations, machine-learning frameworks such as the cores of PyTorch and TensorFlow.
- Embedded and real-time systems — cars, robots, drones, medical devices.
A first look
#include <iostream> #include <string> #include <vector> int main() { std::vector<std::string> languages{"C", "C++", "Rust"}; for (const auto& name : languages) { std::cout << "Hello from " << name << "!\n"; } }
Hello from C! Hello from C++! Hello from Rust!
This program stores three strings in a vector — a list that manages its own memory — and prints a greeting for each. Lesson 3 explains every part.
C++ and C
C++ began as "C with classes", and almost all C code is still valid C++. But modern C++ is written very differently from C:
| Task | C style | Modern C++ style |
|---|---|---|
| Text | char arrays and strcpy | std::string |
| Lists | Arrays plus malloc/realloc | std::vector |
| Memory | malloc and free by hand | Containers and smart pointers that free themselves |
| Errors | Return codes | Exceptions, std::optional, std::expected |
| Generic code | Macros, void * | Templates and concepts |
You don't need to know C to take this course. If you do, the C course gives useful background on memory and pointers.
What makes C++ special
- Zero-overhead abstractions. High-level features like classes, templates and algorithms compile down to code as fast as hand-written low-level code.
- RAII. Objects clean up after themselves when they go out of scope — memory, files, locks — without a garbage collector.
- Multi-paradigm. Procedural, object-oriented, generic and functional styles all work, and mix freely.
- Huge ecosystem. Decades of libraries, tools and expertise.
The trade-off is complexity: C++ is a big language with sharp edges inherited from C. This course focuses on the modern, safer subset you should actually use.
A short history
Bjarne Stroustrup started "C with Classes" at Bell Labs in 1979; it was renamed C++ in 1983 (++ is the increment operator). Since the first ISO standard in 1998 the language has been updated every three years:
| Standard | Highlights |
|---|---|
| C++98/03 | The first standard: classes, templates, the STL containers and algorithms |
| C++11 | "Modern C++": auto, lambdas, move semantics, smart pointers, range-for, threads |
| C++14 / C++17 | Refinements; optional, variant, string_view, structured bindings |
| C++20 | Concepts, ranges, std::format, span, coroutines, modules |
| C++23 | std::print, std::expected, more ranges |
| C++26 | In progress: reflection, contracts and more |
This course teaches C++20, which current GCC, Clang and MSVC support well, and covers the newer C++23 additions in lesson 50.
How this course works
Every example was compiled with a real compiler (Clang 17, using -std=c++20 -Wall -Wextra -pedantic) and run, and the output shown is exactly what it printed. The Try it yourself boxes let you edit an example and copy it to compile on your own computer — set that up in the next lesson.
Try it yourself
Add your own favourite languages to the list and run it again.
I want to learn C++ I want to learn Python I want to learn JavaScript