(unwrapped) pointer assignment — double-pointer scenario 2 again

Before looking at double-pointers, let’s clarify the basic rules. For regular pointers p and q2, (assuming 32-bit),
Rule 1) Foo *p = 0; p = … // pointer p bitwise state change i.e. reseating
Rule 2) *q2 = …// pointer q2 still points to the same pointee, but pointee’s state changed via assignment operator (possibly overloaded)

Now, in http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.17 shows a double pointer
Foo **q = &p; // q points to the address of pointer p

*q = … // q still points to the same 32-bit object, which is pointer p, but p’s content is changed, i.e. p reseated. Means the same as “p = …”
Now we are ready for

Rule 3) SomeType * ptr = … // ptr seating at initialization. This looks like Rule 2 but is really more like Rule 1.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s