Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


pointer to member of class's pointer?

This topic is 5423 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

Okay, i''m pretty sure i said it right in the subject, but let me try and explain: I have a class named "cApp", and an instance of that class named "App". This class has a member variable "m_Font" of the class "cFont", which is... well, a font to draw with. Now i wanted to put all my buttons in a vector, to make it easier to determine whether the mouse was hovering over a button, and if so which one. To make my cButton class flexible though, i figured it best to support both text, colored background and images. Anyway, i''m having trouble with the text part. I want to pass the button handling class (cButtons) the previously mentioned m_Font (as a pointer) to the button handling class so each of the buttons doesn''t have to create a font (which, i''m not sure, but i imagine would be quite a slowdown). Basically, here''s what i wanted to do: App->m_Buttons.Paint(App->m_Mouse.GetXPos(), App->m_Mouse.GetYPos(), App->m_Font*); Again, App is a pointer to an instance of the cApp class, of which m_Font is a member. So how do i get a pointer to the m_Font variable? (so i can pass-by-pointer). The error i get on build is: "error c2059: syntax error: '')'' ". It''s nothing to do with any other lines (like the MSVC++ help suggested). Also, i didn''t search google on this since i''ve no idea what to use as search term...

Share this post

Link to post
Share on other sites
If cApp::m_Font is a pointer:
App->m_Buttons.Paint(App->m_Mouse.GetXPos(), App->m_Mouse.GetYPos(), App->m_Font); // no asterisk!

If it''s an object:
App->m_Buttons.Paint(App->m_Mouse.GetXPos(), App->m_Mouse.GetYPos(), &App->m_Font); // pass address of object

Hope that answers what you''re asking..

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!