next up previous contents
Next: operator-()operator*() Up: ``pvector'' class Previous: Debugging

sum()

  friend Complex sum(const pvector& in)
Return value:

Input:

Write a function of the above prototype using the code for ``operator^'' as a guide. You should place your new routine in ``pvector.C'' within the definition of the pvector class (immediately after the definition of ``operator^'' is a good location). Debug by uncommenting the ``Test sum'' code in main() and compiling and running.

C++ Notes: The modifier ``friend'' simply means that this function has access to all of the internal data of the objects upon which it acts. Also, for your coding, you can ignore the ``const'' and ``&'' for the input argument, and imagine we had declared simply sum(pvector in). The ``const'' and ``&'' are optimizations which tell the compiler not to make unnecessary copies of in.



Tomas Arias
Fri Apr 14 12:12:49 EDT 2000