It's very possible that you won't comprehend this chapter unless you've gone through the C++ Pointers chapter.
So, assuming you know your way around pointers in C++, let's get started: A constant pointer to the array's first element is an array name. As a result, in the statement, there is a double balance[50];
balance is a pointer to &balance[0], the address of the array balance's first entry. As a result, the following software snippet assigns p the address of balance's first element: double *p; double balance[10];
p = equilibrium;
Constant pointers can be used as array names, and vice versa. As a result, *(balance + 4) is a valid method of gaining access to the data at balance[4].
After storing the first element's address in p, you can access array elements with *p, *(p+1), *(p+2), and so on. The following is an example that demonstrates all of the principles stated above.
|