Skip to main content
gamedev.net
🔒 Locked

pointer to pointer

Started by xyuri 5 replies 1.2k views
Original Post
xyuri
xyuri
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
Drazgal
Drazgal
Use (*ipp)->parent
jpetrie
jpetrie
(*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.
Xai
Xai
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.
xyuri
xyuri
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
Aardvajk
Aardvajk
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.