Original Post
hello
I have a query as to how to pass a member function from a class via function pointer..
the example is as follows
class CSound
{
public:
void playSound(int index);
void stopSound(int index);
//Memory Allocation Functions
void MemAlloc(int bytes, int use, int actUse);
void MemFree(void *mem);
};
now i call a function which is the part of the API and pass the functions in the CSound class via function pointer to the function...
sndRegisterMainMemAllocator(MemAlloc, MemFree);
but here the compiler always gives me an error..
error 1297: argument of type "void (*) (int , int, int*)" is incompatible with parameter (1 of sndRegisterMainMemAllocator) of type "ExternSndMemAlloc"
...In C i know just passing the name of the function works...but in c++ i am a little confused whether just passing the name of the member function of the class will work...
i also tried making the member functions as static but then too i get the same error...
Please advice on this....as how to get it working...any suggestions would be most helpful...
I have a query as to how to pass a member function from a class via function pointer..
the example is as follows
class CSound
{
public:
void playSound(int index);
void stopSound(int index);
//Memory Allocation Functions
void MemAlloc(int bytes, int use, int actUse);
void MemFree(void *mem);
};
now i call a function which is the part of the API and pass the functions in the CSound class via function pointer to the function...
sndRegisterMainMemAllocator(MemAlloc, MemFree);
but here the compiler always gives me an error..
error 1297: argument of type "void (*) (int , int, int*)" is incompatible with parameter (1 of sndRegisterMainMemAllocator) of type "ExternSndMemAlloc"
...In C i know just passing the name of the function works...but in c++ i am a little confused whether just passing the name of the member function of the class will work...
i also tried making the member functions as static but then too i get the same error...
Please advice on this....as how to get it working...any suggestions would be most helpful...