11 Jul
2003
11 Jul
'03
23:10
Jerry Feldman wrote:
Also, in both C and C++, making a pointer constant: type_name function( const int *x ){ ... } This makes the int pointed to by x const, but the pointer, x, can be set and reused within the function.
I wasn't thinking about pointers, but I guess it also makes sense to declare type_name function( const int *x ); and define type_name function( const int * const x ){ ... } if you know you're not going to reuse the pointer. I guess the advantage is that it's one less thing to debug or an easy way to check the pointer isn't being reused in a long function. -- JDL Non enim propter gloriam, diuicias aut honores pugnamus set propter libertatem solummodo quam Nemo bonus nisi simul cum vita amittit.