Include Header
Browse / C++ Cheatsheet
C++ Cheatsheet
A comprehensive cheat sheet for C++ programming, covering syntax, data structures, standard library functions, and common algorithms.
Language Fundamentals
Basic Syntax
|
|
|
|
Main Function |
|
|
Output to Console |
|
|
Variables Declaration |
|
|
Comments |
|
|
Input from Console |
|
Data Types
|
|
Integer numbers |
|
|
Floating-point numbers |
|
|
Double-precision floating-point numbers |
|
|
Single characters |
|
|
Boolean values ( |
|
|
Sequence of characters (from |
Operators
|
Arithmetic Operators: |
|
Assignment Operators: |
|
Comparison Operators: |
|
Logical Operators: |
|
Increment/Decrement Operators: |
Control Flow
Conditional Statements
|
If Statement |
|
|
If-Else Statement |
|
|
If-Else If-Else Statement |
|
|
Switch Statement |
|
Loops
|
For Loop |
|
|
While Loop |
|
|
Do-While Loop |
|
|
Break Statement |
Exits the loop. |
|
Continue Statement |
Skips the current iteration. |
Range-based for loop
|
Used to iterate over elements in a range (e.g., arrays, vectors).
|
Functions
Function Definition
|
Basic Structure |
|
|
Example: Add two integers |
|
Function Overloading
|
Defining multiple functions with the same name but different parameters.
|
Function Pointers
|
Definition |
Pointers that store the address of a function.
|
Lambda Expressions
|
Anonymous functions defined inline.
|
Standard Template Library (STL)
Containers
|
|
Dynamic array (from |
|
|
Doubly-linked list (from |
|
|
Double-ended queue (from |
|
|
Sorted set (from |
|
|
Associative array (from |
|
|
Hash table (from |
Algorithms
|
|
Sorts a range of elements (from
|
|
|
Finds the first occurrence of a value in a range (from
|
|
|
Applies a function to a range of elements (from
|