Following the previous examples in which billy had 5 elements and each of those elements was of type int, the name which we can use to refer to each element is the following:
For example, to store the value 75 in the third element of billy, we could write the following statement:
and, for example, to pass the value of the third element of billy to a variable called a, we could write:
Therefore, the expression billy is for all purposes like a variable of type int.
Notice that the third element of billy is specified billy, since the first one is billy, the second one is billy, and therefore, the third one is billy. By this same reason, its last element is billy. Therefore, if we write billy, we would be accessing the sixth element of billy and therefore exceeding the size of the array.
In C++ it is syntactically correct to exceed the valid range of indices for an array. This can create problems, since accessing out-of-range elements do not cause compilation errors but can cause runtime errors. The reason why this is allowed will be seen further ahead when we begin to use pointers.
At this point it is important to be able to clearly distinguish between the two uses that brackets [ ] have related to arrays. They perform two different tasks: one is to specify the size of arrays when they are declared; and the second one is to specify indices for concrete array elements. Do not confuse these two possible uses of brackets [ ] with arrays.
If you read carefully, you will see that a type specifier always precedes a variable or array declaration, while it never precedes an access.
Some other valid operations with arrays: