Discussion: pointer vs reference
Afficher un message
Vieux 05/04/2008, 02h57   #9
Jim Langston
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: pointer vs reference

Eric Kaplan wrote:
> I suppose the following is exact same thing right?
>
> int * const start
> int const * start
>
> both means the pointer is constant - (pointer always point to same
> address)


No. Those are not the same.
const int* start;
int const* start;
are exactly the same.

int* const start;
start is a constant *pointer* to an int. You can not reseat the poniter.
You can not change where the pointer is pointing to. In fact you better
initialize it since you can't change it. But you can change the integer
that the pointer points to.

int const * start;
start is a pointer to a constant *integer* You can not change the value of
what the pointer points to, but you are free to make the pointer point to
some other memory location.


--
Jim Langston
tazmaster@rocketmail.com


  Réponse avec citation
 
Page generated in 0,05523 seconds with 9 queries