Learn C++

Learn C++ from the ground up, one clear example at a time.

Plain answers to common C++ questions, from data types, operators and loops to classes, strings, containers and memory.

386 in-depth guides
100 topics
Nov 2026 latest guide

Featured guides

Guides to start with

Each one links on to more specific articles in its topic.

Is C++ Better Than C?

C++ grew out of C and adds classes, templates, and a large standard library. Neither is better in every case. See how they differ and which suits your goals.

C++ vs C 4 min read

Is C++ Harder Than Python?

For most beginners, C++ is harder than Python because it needs a compiler, explicit types and careful memory handling. See why, with a side-by-side example.

C++ vs Python 4 min read

Rust vs C++ Performance

Rust and C++ both compile to fast native code, so speed gaps are often small. Learn what drives performance in each, and how to read benchmarks fairly.

Rust vs C++ 6 min read

Browse

Explore by topic

See every guide →

Getting Started

Whether to learn C++, how hard it is and how it compares with C, Python, Java and Rust.

Syntax and Functions

Data types, operators, control flow, keywords, functions and the preprocessor.

Primitive Data Types The built in C++ types, type casting and how other languages group data types. 4 guides long long What the long long type holds and when you need a long integer. 2 guides Signed vs Unsigned How signed and unsigned integers differ and how they look in binary. 3 guides double and float What double stores, how big a float is and how to print floating point values. 3 guides Integer Limits The minimum and maximum int values in C++ and how they compare with 1e9. 2 guides sizeof How the sizeof operator measures types in bytes and how big an int really is. 5 guides typeof and decltype How decltype and typeof deduce types, with a look at typeof in JavaScript. 2 guides Enums How enums work in C++ and C, with examples of why you would use one. 5 guides Declaration and Initialization Designated initializers and the difference between declaring and initializing variables and arrays. 5 guides Conditional Operator How the ternary conditional operator works and how conditional statements are written. 2 guides Comparison Operators The operators that compare values in C++ and how logical OR fits in. 3 guides Assignment Operators Plain and compound assignment, plus the address and dereference operators. 5 guides Increment Operator How prefix and postfix increment differ and when ++i is the better choice. 4 guides Unary Operators The operators that act on a single operand and how they differ from ternary ones. 3 guides Shift Operators How left and right shifts move bits, with small examples like 1 << n. 4 guides Bitwise Operators XOR, NOT and the other bitwise operators, and how & differs from &&. 4 guides Power Operator Whether C++ has an exponent operator and how to raise numbers to a power. 1 guide Logical and Arithmetic Operators The OR operator and an overview of arithmetic and other C operators. 3 guides Dot and Scope Operators How the dot operator reaches members and what the :: operator means. 5 guides While Loops While loop syntax with examples and the three main kinds of loops. 3 guides Do While Loops Example do while programs and how they compare with for and while loops. 2 guides Break Statement How break exits loops and switch statements early. 1 guide Switch Case How switch case statements work and when they beat a chain of ifs. 2 guides If Else Statements If else syntax and how to build an else if ladder. 3 guides goto What the goto jump statement does and how to use it in C and C++. 4 guides Recursion How recursive functions work, why they need a base case and how they look in Python. 5 guides Function Overloading Function overloading in C++, how it differs from overriding and from operator overloading. 5 guides Function Prototypes What a function prototype is and how it relates to a function definition. 4 guides Static Functions What static does to functions and variables and when to use it. 5 guides inline What the inline keyword does and how inline functions differ from macros. 4 guides const How const works in C++, the C keyword list and const in JavaScript. 5 guides using namespace std What namespaces are, what std means and when to write std:: yourself. 5 guides using The roles of the using keyword in C++, plus the ternary operator. 2 guides cout How to print output with std::cout and the << operator. 4 guides Lambda Functions How C++ lambdas are written, what type they have and why they are useful. 5 guides std::function How std::function stores callable objects, plus count() and the types of functions in C. 3 guides Functions as Arguments How to pass a function to another function using pointers and other callables. 3 guides Function Pointer Arrays How to build arrays of function pointers, starting from what an array is. 3 guides Header Guards How header guards stop a file from being included twice. 3 guides Header Files What .h files are for, with a worked C++ header file example. 5 guides The Preprocessor What the preprocessor does to your code before it is compiled. 3 guides Macros How macros work, how to stringify one and why C++ often avoids them. 4 guides

Classes and Design

Structs, classes, object oriented features and the principles behind well organized code.

Struct vs Class How structs and classes differ in C++, starting with default member access. 5 guides Struct Constructors How to give a struct a constructor and when a struct is the right choice. 4 guides Constructors What class constructors do, why classes need them and how Python handles the same idea. 4 guides Inheritance How one class builds on another in C++, explained in simple terms. 5 guides Polymorphism What polymorphism means, its main types and how it differs from inheritance. 5 guides Encapsulation How classes hide their data behind a public interface, with examples. 5 guides Abstract Classes What abstract classes are for and how they support abstraction in OOP. 4 guides Friend Functions How friend functions and friend classes reach private members, plus the types of inheritance. 3 guides Access Modifiers Public, private and protected in C++, compared with Java, C# and Apex. 5 guides Operator Overloading How to define operators for your own types and which ones cannot be overloaded. 5 guides Static Classes How to get static class behavior in C++ and what static means in C. 4 guides final How final stops a class or virtual function from being extended, plus the C++ keyword list. 3 guides Template Metaprogramming How templates run code at compile time and how this differs from the C preprocessor. 5 guides SOLID Principles The five SOLID principles applied in C++ and how they relate to clean code. 5 guides Dependency Injection How dependency injection works in C++, its main forms and what a container does. 5 guides Concurrency How C++ runs work in parallel with threads and what concurrency means in an operating system. 4 guides

Strings, Containers and Memory

Working with strings, arrays and standard containers, plus how memory works and how to debug it.

String Methods The main std::string member functions and how C strings work. 4 guides Finding in Strings How to use find() to locate characters and substrings in a string. 2 guides String Contains How to check whether a string holds a substring, plus the C string.h library. 4 guides Comparing Strings How to compare strings in C++ and C, including strcmp and the == operator. 5 guides Concatenating Strings How to join strings together in C++ and what concatenation means. 5 guides Reversing Strings How to reverse a string with std::reverse and why strrev often fails. 5 guides Iterating Over Strings How to loop through the characters of a string and other basic string operations. 4 guides Splitting Strings How to split a string on a delimiter in C++, compared with split() in C# and Python. 5 guides stringstream How stringstream, getline and the stream classes parse and build strings. 5 guides Reading String Input How to read text input in C++ and related functions like strstr. 3 guides Switching on Strings Workarounds for using strings in a switch, plus switch basics in C. 5 guides String to Int How to turn a string into an integer with stoi, atoi and similar tools. 5 guides Int to String How to turn numbers into strings and convert C strings to std::string. 3 guides Char to Int How to convert a char to an int, how big a char is and how to_string helps. 4 guides Vector Initialization Ways to create and fill a std::vector, and how size and resize work. 4 guides Dynamic Arrays and Linked Lists Using std::vector as an ArrayList and how linked lists differ from arrays. 5 guides std::array How std::array gives fixed size arrays a safer interface. 4 guides std::list How the std::list container works and what the std:: prefix means. 4 guides List vs Array When to pick a list or an array, with comparisons from C# and Python. 5 guides Dictionaries with std::map How std::map works as a dictionary and the main data structures in C. 4 guides Hash Sets How std::unordered_set works and how hash sets compare with maps and lists. 5 guides std::set How std::set keeps unique sorted values, with a note on sets in Python. 2 guides Tuples How std::tuple groups values and how tuples compare with lists in Python. 5 guides std::optional How std::optional represents a value that may be missing. 2 guides Returning Arrays Ways to return an array from a C++ function and how char arrays and pointers differ. 4 guides Passing Arrays How arrays are passed to functions and what actually gets passed. 3 guides Arrays of Structs How to store structs in an array and how structs and arrays differ. 3 guides Random Numbers How to generate random numbers in C++ and the limits of rand and srand. 5 guides NULL vs nullptr Why C++ added nullptr, how it differs from NULL and 0 and what null pointers are. 5 guides Heap vs Stack How stack and heap memory differ and where your variables live. 5 guides Segmentation Faults What causes a segmentation fault and what SIGSEGV means. 5 guides Modifiable Lvalue Error What lvalues are and how to fix the expression must be a modifiable lvalue error. 3 guides Valgrind and Memory Leaks How to find memory leaks with Valgrind and set up a program for GDB. 5 guides