c Cheatsheet Inc c 2011

Share Embed Donate


Short Description

mbnnbvbc...

Description

C++ Cheatsheet(inc. C++2011) Cheat Sheet by Leupi Leupi via  via cheatography.com/5907/cs/1197/ 

Standard Sytemtypes and their range

Nullpointer

Basic Operators

int8_t

-128 to 127

int* pInt;

+

addition

u i n t8 _ t

0 t o 25 5

-

subtraction

*

multiplication

 //old, deprecated: if(pInt == NULL)

int16_t

-32768 to 32767

u i n t1 6 _ t

0 t o 65 5 35

if(pInt == nullptr)

 /

division

in t3 t32_ t

-2 14 1474 83 836 48 48 t o 21 21 47 4748 36 364 7

 //still valid:

%

m o du l o

++va ++v ar

increase before

uint32 _t _t

0 t o 42 94 9496 72 729 5

int64_t

-9.2 * 1018 to 9.2 * 1018

u i n t6 4 _ t

0 to 1.8 * 1019

Literals & Co. 255

I n te g e r

0xaf

Hexadecimal Integer

1234.0

double

234. 243f

float

true

b oo l

"Hello World"

string/c-string

'a'

char

Preprocessor #include

Includes standard header file

 //new:

if(!pInt)

evaluation Bitwise Operators var++ Bitwise AND

|

Bitwise OR

condition ? result :

short form of if-like

^

Bitwise XOR

alternative;

structure

~

Bitwise NOT

::

Scope Operator



pointer-to-member

>>

Shift right

.

Access member

>

Bitshift(with streams:

Test of equality

!=

Test of non-equality

<

Less than

>

Greater than Less than or equal

content) or defines a variable to be a pointer

Pointers: Quick and dirty

LIB

#include

Includes Header.h file

>=

Greater than or equal

!

NOT

&&

AND

||

OR

Defines Easy Macro

3.14159265359 #define f(a,b)

More Complex Macro

a+b

input/output)

==



#define PI

evaluation

Boolean Logic



Dereferences pointer(returns it´s

Access p oi ointe r class memb er er. sa same as (*pointer).member()

new ne w

Crea Cr eate te ne new w ob obje ject ct on he heap ap,, ret retur urns ns pointer to object

Boolean expressions in C++ are evaluated leftto-right!

delete dele te

Remove Rem ove obj object ect at the poin pointer ter on heap

#undef PI PI

Remove De Definition

Pointers allocate space on heap, normal

#ifdef PI PI

Checks fo for de definition, ifif tr true,

variables on stack!

code will be compiled #else

Else part of the above ifstatement

#end i f

Ends the if-statement

By Leupi

Published 18th August, 2013.

Sponsored by Readability-Score.com

cheatography.com/leupi/ 

Last updated 18th August, 2013.

Measure your website readability!

Page 1 of 2.

https://readability-score.com

C++ Cheatsheet(inc. C++2011) Cheat Sheet by Leupi via cheatography.com/5907/cs/1197/ 

using replaces typedef

Range based loops

 //typedef is deprecated

 //Easy range based loop:

typedef uint32_t uint32;

std::vector vec = .....;

 //now: using directive!

for(int i : vec) //foreach i in vec

 //using identifier = type_name;

 //Same with auto:

using uint32 = uint32_t;

const auto vi = ....; for(auto i : vi)

Auto Datatype

Works with all Containers with begin() and

 //auto is an automatic datatype:

end()

int x = 4; //equals: auto y = 4;  //works for most cases, esp. STL: for(std::vector::Iterator it = v.begin().....)  //with auto: for(auto it = v.begin; it != v.end(); ++it)

Compile-time assertion check static assert(bool_constexpr, string)

Multithreading  //Thread Creation & Management: void thread_func(int a) { std::cout
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF