C++ quick reference
C++20 (GCC 14) essentials: std::cout and types, control flow, functions and references, classes, the standard containers and algorithms, std::string, input and files, several source files — and how g++ builds and runs your project in Zerethon IDE.
Written for C++ (GCC 14). Examples that show an output were run in the Zerethon sandbox (C++ (GCC 14)) on 2026-10-20.
Basics
-
Hello, World
A
mainfunction,#include <iostream>andstd::cout. -
Variables and types
Built-in types,
auto,const,std::string, conversions, and integer division. -
Conditions and loops
if/else,switch,for, the range-basedfor, andwhile. -
Functions, references and lambdas
Pass by value or by reference, default arguments, overloading, templates and lambdas.
-
Classes and structs
Classes with members and constructors,
structfor plain data, and smart pointers instead ofnew/delete.
Data
-
vector, map, set and algorithms
std::vector,std::map/std::unordered_map,std::set, and sorting and searching with<algorithm>. -
Strings and regular expressions
std::stringmethods, building text withstd::ostringstreamandstd::format, splitting, and<regex>.
Input and files
-
Reading input (stdin)
Read what you type in the IDE's Input tab with
std::cinandstd::getline. -
Reading and writing files
Read project files with
std::ifstream; write temporary files under/tmpwithstd::ofstream. -
Header files and several sources
Declarations in a
.hpp/.hfile, definitions in a.cppfile; the IDE links them into your program.
In Zerethon IDE
-
Running C++ in Zerethon IDE
How Run compiles your project with g++, the flags it uses, the time limit, input and tests.
-
Common errors
Compiler errors (“was not declared in this scope”, “no match for operator”), linker errors, and crashes.
-
Official documentation
Where to read more: cppreference.com, the C++ Core Guidelines and the GCC manual.