Jump to content
  • Advertisement
Sign in to follow this  
xyuri

pointer to pointer

This topic is 4571 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
(*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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
Guest 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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!