"Ian Collins" <ian-news@hotmail.com> wrote:
http://www.research.att.com/~bs/bs_faq2.html#pointers-and-references
Puts a different view across, so one of my guesses was probably true.
I'd only recommend using pointers when the argument can meaningfully be
NULL, or when interfacing with legacy code.
I was actually debating this with myself 2 days ago. Someone gave me some
code work on, he was using pointers to modify the parameters. I started to
change them to references, then realized that in mainline, there is no
indication if the parameter was going to be changed or not.
Consider.
void foo( int* Val )
{
*Val = 23;
}
void bar( int& Val )
{
Val = 23;
}
int main()
{
int MyInt = 10;
foo( &MyInt );
bar( MyInt );
}
Becaue Foo forces us to take the address of MyInt, it is fairly obvious in
mainline that MyInt is probably going to be changed, else why pass the
address of a simple int? bar however gives no indication in mainline that
MyInt will be changed.
A good example of why you should give functions meaningful names.