C++ Tutorial
Learn C++ from scratch: syntax, functions, pointers, classes and std::vector
Beginner to Intermediate6 lessonsabout 30 min of reading
This C++ tutorial is for students, self-taught developers and engineers coming from languages like Java or Python who want to understand how code really runs close to the machine. You do not need prior C++ experience. You do need a C++ compiler such as g++ or clang++, which the first lesson shows how to install and use.
By the end you will be able to compile and run C++17 programs, choose sensible types, write functions that pass data by value or by reference, understand what pointers and references are (and the bugs they cause), and model real things with classes and store them in a std::vector. These are the building blocks behind competitive programming, systems work, game development and many coding interviews.
The lessons are ordered so each one builds on the last: how a C++ program is built and run, then variables and types, then decisions and loops, then functions, then pointers and references, and finally classes with std::vector. Every example is a complete program or a clearly scoped snippet, with the output you should expect.
C++ lessons
- 1C++ Introduction: Syntax, Compiling and Your First ProgramStart C++ the right way: learn what the language is, how compiling and linking work, install a compiler, and write and run your first C++ program.5 min read
- 2C++ Variables and Data TypesLearn C++ variables and data types: int, double, char, bool, std::string, auto, const, type sizes, casting and the pitfalls that cause bugs.5 min read
- 3C++ If-Else, Switch and LoopsMaster C++ if-else, switch, for, while, do-while and range-based for loops, plus break and continue, with working examples and common mistakes.5 min read
- 4C++ Functions: Parameters, Return Values and OverloadingLearn C++ functions: parameters, return values, pass by value vs reference, const references, default arguments, overloading and recursion with examples.5 min read
- 5C++ Pointers and References ExplainedC++ pointers and references explained simply: address-of, dereference, nullptr, const pointers, new and delete, smart pointers and the bugs to avoid.5 min read
- 6C++ Classes, Objects and std::vectorLearn C++ classes, objects, struct vs class, constructors, access specifiers and std::vector basics, with a combined student gradebook example.5 min read
Preparing for an interview? Practise C++ interview questions
Learning C++ to land a job? Browse open roles or check which skills are trending.