Pointer to Pointer blackout question

Started by
12 comments, last by PureSnowX 11 years, 3 months ago
But then why does assigning it to a normal pointer THEN assigning that pointer to a pointer-to-pointer work?
It doesn't. It compiles, but compiling is different from doing what you expect. It gets you the address of the copied pointer, not a pointer to the original pointer.
Advertisement
But then why does assigning it to a normal pointer THEN assigning that pointer to a pointer-to-pointer work?
It doesn't. It compiles, but compiling is different from doing what you expect. It gets you the address of the copied pointer, not a pointer to the original pointer.

Because everything is return/pass by value? Is that why we only receive a copy of a pointer/copy of a reference object?

[quote name='Moonkis' timestamp='1356814024' post='5015527']
Because everything is return/pass by value? Is that why we only receive a copy of a pointer/copy of a reference object?
[/quote]

At the heart of it, everything is always "pass by value". When you pass in or return a reference or pointer, the value of this reference or pointer (an address) are passed by value and therefor copied.

Because everything is return/pass by value? Is that why we only receive a copy of a pointer/copy of a reference object?

At the heart of it, everything is always "pass by value". When you pass in or return a reference or pointer, the value of this reference or pointer (an address) are passed by value and therefor copied.

Yeah that is what I meant, though it's easy to forget that when dealing with pointers and references ( since I did ) in the beginning. Because they "act" like a magical solution that makes you modify the values from anywhere instead of just locally.

Nearly all books I'v read has failed to mention that EVERYTHING is at heart pass by value, especially when introducing pointers.

This topic is closed to new replies.

Advertisement