pointer to member of class's pointer?

Started by
1 comment, last by kVandaele 20 years, 3 months ago
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...
Advertisement
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..
that would be the second (it''s an object, i''m no good when it comes to pointers ), and thanks, that fixed it!

This topic is closed to new replies.

Advertisement