|
-
January 10th, 2011, 05:38 AM
#4
Re: Callback (TIMERPROC) to a c++ class function ??
 Originally Posted by pepsidrinker
So setting the callback to , let's say:
Animation a1;
SetCallback(a1.Draw);
That should be:
Code:
Animation a1;
SetCallback(&Animation::Draw);
That would solve the "many instanciations" problem, wouldn't it ?
If the Draw function is static, it knows nothing about individual Animation object instances.
Code:
class Draw
{
public:
int x; // non-static member
static void Draw()
{
x = 1; // error
}
};
The Draw() function, since it's static, cannot access x, since x only exists for Animation object instances, and there is no instance of an Animation object for static functions.
I guess my knowledge of how memory manage c++ classes is a bit rusty, but if you don't mind enlighting me on why a pointer to a non-static function in an INSTANCIATED object absolutely needs to be declared with the class scope, that would help me a lot.
I would have thought the link I gave you answered most, if not all questions concerning pointers to member functions.
Regards,
Paul McKenzie
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|