next up previous contents
Next: Using const Up: Parameter Passing Previous: Parameter Passing   Contents

What does a pointer imply?

There a couple of base assumptions you should always consider:

  1. If you pass an object pointer to a function, it is highly possible that the function changes the data pointed to.
  2. If you simply pass the object to a function, it is unlikely that the object will be modified within the function.


8#8


9#9

Or even worse:


10#10

This is simply evil to construct a function in this manner. It is not implied from the calling perspective of the function (other than the name of the function) that the object passed will be modified and in this case the name does not imply anything. An exception is something like getNext(int &nPos), where the name of the function hints to the action taken on the object. In this case it is acceptable (but not recommended) to use a non-const reference.



Falko Kuester 2001-08-24