c++ syntax cheatsheet code example
Example 1: C++ CHEAT SHEAT
#include <future> // Include future
function<int(int)> fib = // Create lambda function
[&](int i){
if (i <= 1){
return 1;
}
return fib(i-1)
+ fib(i-2);
};
future<int> fut = // result of async function
async(launch::async, fib, 4); // start async function in other thread
// do some other work
cout << fut.get(); // get result of async function. Wait if needed.
Example 2: c++ cheat sheet
255, 0377, 0xff // Integers (decimal, octal, hex)
2147483647L, 0x7fffffffl // Long (32-bit) integers
123.0, 1.23e2 // double (real) numbers
'a', '\141', '\x61' // Character (literal, octal, hex)
'\n', '\\', '\'', '\"' // Newline, backslash, single quote, double quote
"string\n" // Array of characters ending with newline and \0
"hello" "world" // Concatenated strings
true, false // bool constants 1 and 0
nullptr // Pointer type with the address of 0