Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ cheat sheet

                            // Comment to end of line
                            /* Multi-line comment */
#include  <stdio.h>         // Insert standard header file
#include "myfile.h"         // Insert file in current directory
#define X some text         // Replace X with some text
#define F(a,b) a+b          // Replace F(1,2) with 1+2
#define X 
 some text                  // Multiline definition
#undef X                    // Remove definition
#if defined(X)              // Conditional compilation (#ifdef X)
#else                       // Optional (#ifndef X or #if !defined(X))
#endif                      // Required after #if, #ifdef
Comment

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)
'
', '', ''', '"'      // Newline, backslash, single quote, double quote
"string
"                  // Array of characters ending with newline and 
"hello" "world"             // Concatenated strings
true, false                 // bool constants 1 and 0
nullptr                     // Pointer type with the address of 0
Comment

c++ cheat sheet

x=y;                        // Every expression is a statement
int x;                      // Declarations are statements
;                           // Empty statement
{                           // A block is a single statement
    int x;                  // Scope of x is from declaration to end of block
}
if (x) a;                   // If x is true (not 0), evaluate a
else if (y) b;              // If not x and y (optional, may be repeated)
else c;                     // If not x and not y (optional)

while (x) a;                // Repeat 0 or more times while x is true

for (x; y; z) a;            // Equivalent to: x; while(y) {a; z;}

for (x : y) a;              // Range-based for loop e.g.
                            // for (auto& x in someList) x.y();

do a; while (x);            // Equivalent to: a; while(x) a;

switch (x) {                // x must be int
    case X1: a;             // If x == X1 (must be a const), jump here
    case X2: b;             // Else if x == X2, jump here
    default: c;             // Else jump here (optional)
}
break;                      // Jump out of while, do, or for loop, or switch
continue;                   // Jump to bottom of while, do, or for loop
return x;                   // Return x from function to caller
try { a; }
catch (T t) { b; }          // If a throws a T, then jump here
catch (...) { c; }          // If a throws something else, jump here
Comment

PREVIOUS NEXT
Code Example
Cpp :: c ++ The output should be (abc),(def),(ghw) 
Cpp :: how atan work c++ 
Cpp :: flipperRSocketResponder.cpp command failed react native 
Cpp :: string class in c++ 
Cpp :: c++ calling variable constructor 
Cpp :: Maximum Weight Difference codechef solution c++ 
Cpp :: taking integer input from file in c++ 
Cpp :: two dimensional array A[N,M] with the random numbers from 10 to 90. 
Cpp :: curl upload folder and subfolders 
Cpp :: idnefier endl in undefince 
Cpp :: Road sign detection and recognition by OpenCV in c 
Cpp :: c++ fstream read line write ,creat file program 
Cpp :: How to remove the % in zsh that show after running c++ file 
Cpp :: c++ bind port 
Cpp :: selection sort algorithm in cpp 
Cpp :: static member fn , instance 
Cpp :: why wont a function stop C++ 
Cpp :: . Single-line comments start with two forward slashes (//). 
Cpp :: c++ iterator shorthand 
Cpp :: Nested ternary operator C++ 
Cpp :: CPP Find options passed from command line 
Cpp :: c++ correct upto 3 decimal places 
Cpp :: servicenow cart api 
Cpp :: flowchart to display factors of a number 
Cpp :: how to find the left most bit 1 in binary of any number 
Cpp :: c++ cout format specifier for correct number of decimal points 
Cpp :: print the elements of the array without using the [] notation in c++ 
Cpp :: how to show c++ binary files in sublime text 
Cpp :: Patrick and Shopping codeforces in c++ 
Cpp :: play sound opencv video c++ 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =