Show Menu
Cheatography

C++ Basics to Advanced Cheat Sheet (DRAFT) by

101 of C++ language.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Shortcuts

ctrl + /
Comment line
shift + alt + up/down
Duplicate line
alt + up/down
Move line
ctrl + [/]
indent left/right

<ve­cto­r> (Use vector)

vectorName.push_­back()
add element
vectorName.pop_b­ack()
remove last element
vectorName[ index ]
access element at index
vectorName.at( index )
access element at index
vectorName.erase( index )
erase element at a index
vectorName.size()
find vector size
.at (better due to bounds checking)

<io­str­eam> (Standard library)

cin >> a,b
get input
cout << "­Hel­lo"
print output + endline
cerr << "­Error: warnin­g"
standard error message
endl
endline and move to next line
flush
immedi­ately prints the output without buffering
cin.fail()
checks if the last input/­output operation on a stream failed.
clog
 

<cm­ath> (Math operat­ions)

sqrt(var)
Square value

<cs­tdi­o> (C style operat­ions)

printf()
Formatted print