
2008/5/16 Kevin Martin
func1() may be a member function of an object which needs to keep the argument somewhere, that is why I prefer to pass a pointer.
If it is keeping the argument, then it cares about ownership/lifetime, so one should pass a smart pointer to it.
Passing a reference gives the implication (at least to me) that the object is not going to keep any link with the argument after the call returns. Passing a pointer makes me think - hey, what is this object doing with this thing?
It doesn't convey that information to other readers of your code. All the language rules really give you is that passing by reference means that the variable must exist, while passing by pointer means that it could be NULL. -- Nevin ":-)" Liber mailto:nevin@eviloverlord.com (847) 691-1404