2009/7/23 Kenneth Riddile <
kfriddile@xxxxxxxxx>:
> I'll chime in here...When I see a function that takes any type of pointer
> (const/non-const) as a parameter, this signals to me that null is a valid
> value to pass to the function.. If null is not a valid value, then the
> argument should be passed by
reference. As far as whether or not it's
> obvious from the call site whether the argument may be modified, one has to
> assume that a user/maintainer will look at the signature of the function
> when trying to understand its purpose. A function's signature is its public
> interface after all.
I concur. The only place pointers should be used is where the value
might be NULL. However this doesn't include cases like this:
int atoi(int x, bool* error = NULL);
In that case I think it would be better to have to have two functions:
int atoi(int x);
int atoi(int x, bool& error);