Nearly drowning in C++
OK, I’ve decided to do it. To leave the elegance of Objective-C and have a closer look at C++. After all, isn’t everyone doing oF these days? Here a recapitulation of usesful C and some quick notes on C++ peculiarities – sorry – features: (That might be a good place to start.) Initialisation int a = 1; // standard c way int b(1); // same Defined constants #define PI 3.1415927 // faster than var Declared constants const int c = 100 // immutable Assignment = can also be used as rvalue a = 1 + (b = 2); same as: b = 2; a = 1 + b; Comma operator a = (b=3, b+2); // a = 5
When the set of expressions has to be evaluated for a value, only the rightmost expression is consideredType casting int i, j; float f = 1.234; i = (int) f; j = int (f); sizeof() One parameter, either a type or a variable and returns the size in bytes. a = sizeof (char); Will become important with arrays.