C++ Quick Reference
Modern C++: I/O, strings, vectors, maps, algorithms, classes, smart pointers, lambdas and compiling.
6 sections · 34 snippets · updated Oct 14, 2026
Click any snippet to copy it.
Basics
Program structure and I/O.
TaskCode
- Hello world
- Variables
- Read input
- Read a whole line
- Format (C++20)
Strings
std::string.
TaskCode
- Create / length
- Concatenate
- Substring / find
- Convert numbers
- Compare
Containers
Vectors, maps and sets.
TaskCode
- Vector
- Access / size
- Loop
- Map
- Hash map / find
- Set
- Pair / tuple
Algorithms
<algorithm> and ranges.
TaskCode
- Sort
- Sort descending / by key
- Find
- Count / sum
- Min / max
- Reverse
Classes & memory
Objects and ownership.
TaskCode
- Class
- Inheritance
- Virtual method
- Unique pointer
- Shared pointer
- Lambda
- Struct
Errors & building
Exceptions and compiling.
TaskCode
- Try / catch
- Throw
- Optional
- Compile