Range for (range for)
1 for (declaration:expression)
2 statement
Vectors and arrays are collections of objects, and references are not objects.
Vector objects can grow more efficiently, and it is not necessary to set their size when defining a vector object, in fact, if the performance may be worse.
C++11 new features: Cbegin () & Cend ()
To make it easier to get the return value of the Const_iterator type specifically, the c++11 new standard introduces two new functions, Cbegin () and Cend () respectively.
How do you understand complex array declarations?
1 int *ptrs[10]; Ptrs is an array that contains 10 integer pointers
2 int &refs[10] =/*?*/; Error, no referenced array
3 int (*parray) [+] = &arr; Parray points to an array containing 10 integers
4 int (&ARRREF) [ten] = arr; Arrref refers to an array containing 10 integers
For Parray, it's not reasonable to read from right to left. Because the dimensions of an array are followed by the declared name, it is much better to read from the inside than from right to left for an array.
The first is inside the parentheses, *parray means the parray is a pointer;
Next, on the right, Parray is a pointer to an array of size 10;
Finally, look to the left and know that the elements in the array are int.
1 int ia[5];
2 Auto Ia2 (IA); IA2 is an integer pointer
3 Decltype (IA) ia3; IA3 is an array that contains 10 integers
C++11 new features: standard library function begin () and end ()
To make the pointers more secure and simpler to compute, the new C++11 standard introduces two functions named Begin and end, which are used to compute the iterator of the array.
How multidimensional arrays are accessed
1 int ia[3][4];
2 for (auto P = ia; p!= ia + 3; ++p)
3 {
4 for (Auto q = *p q!= *p + 4; ++q)
5 & nbsp; {
6 // Do something
7 }
8 }
9
10 for (auto P = Begin (IA), p!= End (IA); ++p)
11 { br> 12 for (auto q = Begin (*p), Q!= End (*p); ++q)
13 &nbs p; {
14 //do something
15 }
16 }