Although the trailing pointers can be computed, this usage is extremely error-prone. To make the use of pointers easier and more secure, the new C + + standard introduces two functions called Begin and end. These two functions are similar to the two members of the same name in the container, although the array is not a class type after all, so these two functions are not member functions. The correct form of use is to have arrays as their parameters:
int a[] = {0,1,2,3,4,5,6,7,8,9};int *beg = Begin (a);//Pointer to a first element int *last = end (a);//Pointer to the next position of a tail element
Cannot use dynamic array
These two functions are defined in the iterator header file.
Using these two functions makes it easy to write a loop and manipulate the elements in the array. For example:
int *pbeg=begin (a), *pend=end (a), while (pbeg!=pend&&*pbeg>=0) ++pbeg;
Note, in particular, that the trailing pointer cannot perform dereference and increment operations.
Standard library functions begin and end------C++primer