Home Segments Index Top Previous Next

376: Mainline

Finally, the original program contains a for loop that computes the sum of the prices of the trade objects; the argument handed to trade_price is the address of an array item:

for (counter = 0; counter < limit; ++counter) 
  sum = sum + trade_price (&trades[counter]); 
                           ----------------- 
                                  ^ 
                                  *-- An address 

The for loop in the modified program is nearly identical; the address-of operator disappears, however, because array items are the addresses of objects, rather than objects themselves:

for (counter = 0; counter < limit; ++counter) 
  sum = sum + trade_price (trade_pointers[counter]); 
                           ----------------------- 
                                  ^ 
                                  *-- Also an address