pointer to pointer

Started by
5 comments, last by Aardvajk 17 years, 10 months ago
I am writing a function using borland c++ builder 6 to accept a pointer to a pointer to an image ;) (yes, pointer to pointer) but the syntax doesnt seem to work for me. this is my function header: void __fastcall TForm1::AdjustImage (TImage** ipp, int v, int h) now that compiles fine, but the errors come when I need to dereference (and derefence again) that ipp variable. A TImage has a "parent" properly, but "**ipp.parent" doesnt work, the "ipp->->parent" approach doesnt work either. How is this done?
__________Michael Dawson"IRC is just multiplayer notepad." - Reverend
Advertisement
Use (*ipp)->parent
(*ipp)->parent or (**ipp).parent.

**ipp.parent will not work due to precedence; direct member access (. operator) is higher on the list than deference (* operator); thus the parens.
just remeber this simple policy (which is true about 80% of the time):

any time you use * to dereference with ANY OTHER member operations, you should enclose it in parenthesis.

so when you do:

(*it).Foo();

or

(*it)->SomeFunc();

but not necesasry when put with non-member expression / statement operators:

curr = prev
*curr = *prev
(*curr).next = *prev

etc.
Thank you both for your responses :) I have the feeling that this has happened to me in the past then forgotten about it :(

Thanks again :)
__________Michael Dawson"IRC is just multiplayer notepad." - Reverend
Quote:Original post by xyuri
..blah.. a pointer to a pointer to an image ;) (yes, pointer to pointer)


Is this supposed to be something clever? A pointer to a pointer, big wow.

Quote:Original post by Anonymous Poster
Quote:Original post by xyuri
..blah.. a pointer to a pointer to an image ;) (yes, pointer to pointer)


Is this supposed to be something clever? A pointer to a pointer, big wow.


Thanks for the contribution. Do feel free to log in next time.

This topic is closed to new replies.

Advertisement