{} to initialise variables
int w = 3.4;
int x1 {6};
int x2 = {8}; // = here is optional
int y {'k'};
//int z {6.4}; // Error!
{} can not be used for narrowing process, thus the last line will not be working
For (), you can use them to initialise global variable, but not data members
A range for function to replace for loops
It is more like a function(The variable will be killed after the scoop)
cout << "Square some numbers in a list" << endl;
for (int k : {0, 1, 2, 3, 4})
cout << k*k << endl;
int range[] { 2, 5, 27, 40 };
cout << "Square the numbers in range" << endl;
for (int k : range) // Won't change the numbers in range
cout << k*k << endl;
cout << "Print the numbers in range" << endl;
for (int v : range) cout << v << endl;
for (int& x : range) // Double the numbers in range in situ
x *= 2;
cout << "Again print the numbers in range" << endl;
for (int v : ran
int a = 10;
int *p = &a;
cout << a << endl;
// This will print out the address of A
char b = 'A';
char *q = &b;
cout << b << endl;
// This will print out 'A'
// Since the definition of a string is const *char
struct = class {public}
class == struct{private}
There can also be functions inside the structure
Class can have prototypes similar to functions
class Cell; // Forward declaration of Cell
class List
{
int size;
Cell* data; // Points to a (forward-declared) Cell object
//Cell x; // Error: Cell not defined yet!
};
class Cell // Definition of Cell
{
int info;
Cell* next;
};