If you''re trying to make a function pointer that points to a function inside a class, this is the syntax:
void (CWorld::*ptr)();
In this example you can point "ptr" to any function in CWorld with the appropriate prototype.
Function Pointers
The comment beside the call in MsgPump sounds like it thinks you haven''t pointed RenderFuncPtr to anything yet.
Try changing:
"RenderFuncPtr RenderFunc();"
to this:
"RenderFuncPtr RenderFunc;"
I think the first one is a new function that returns a RenderFuncPtr, the second is a function pointer.
Try changing:
"RenderFuncPtr RenderFunc();"
to this:
"RenderFuncPtr RenderFunc;"
I think the first one is a new function that returns a RenderFuncPtr, the second is a function pointer.
That didn''t work either, i tried ;P
I''ve decided to take a new approach - see COM & DirectX References msg thread...
I''ve decided to take a new approach - see COM & DirectX References msg thread...
I can do this! and I''m still only learning C++.
I can''t remember how to do it now (sorry, it''s at home), but I found it in the MS VC help thingy, and it''s very similar to what Baskunen suggested in his first post.
George.
"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"
I can''t remember how to do it now (sorry, it''s at home), but I found it in the MS VC help thingy, and it''s very similar to what Baskunen suggested in his first post.
George.
"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"
quote:Original post by GEo
I can do this! and I''m still only learning C++.
I can''t remember how to do it now (sorry, it''s at home), but I found it in the MS VC help thingy, and it''s very similar to what Baskunen suggested in his first post.
George.
"Who says computer games affect kids, imagine if PacMan affected us as kids, we''d all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"
That first post wasn''t a class contained function, nor did it go into a class.
It works with static methods (which makes perfect sense) and doesn''t with non-static methods, which also makes sense... If you have a working example of a function pointer property that points to another class''s (non-static) method - I be happy to see it! It very clurgy idea though, I''ve thought of a better way to do it... well, a different way anyhow
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement