Re: [Dev-C++] my delete function in my linked list
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Luigi S. <gi...@li...> - 2001-11-11 14:21:31
|
Hi
AFAIK it is common practice to use pointers instead of references when a
functions needs to change some of its parameters, the reason is the one
pointed out by Jason:
when a routine requires a reference parameter, the user may not think that
it will be modified, on the other hand passing a pointer (of course non
const) stresses the fact that the parameter will be changed.
To make it clearer, one should use: "void swap(int *pa, int *pb);"
instead of "void swap (int &a, int &b);"
Of course there are cases when you are forced to use references:
overloading the stream insertion operator (">>")is one of these; more
often, for efficiency reasons, one finds some parameter passed as a const
referece: this is safe because of the const.
At 02.25 10/11/01 +0000, Jason Hardman wrote:
>The main reason was to avoid the use of *&, I personally believe that
>using reference to a pointer, in main(), is a bad way of doing things. ...
>
--
gisan
gi...@li...
|