Function Pointers

Started by
23 comments, last by Shannon Barber 23 years, 10 months ago
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.
Advertisement
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.
That didn''t work either, i tried ;P


I''ve decided to take a new approach - see COM & DirectX References msg thread...
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
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!"

George. F"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