Click to See Complete Forum and Search --> : signal handling and function pointers.


verbal
March 28th, 2008, 12:27 PM
I want to handle the interrupt signal, and when i do that, the function called to be dependent on whats the program's condition is. I mean that i want to print the result for the operation running when interupted even if it hasn't finish but this could vary between some operations so i need to choose the function to be called.

The problem here is that these functions i want to choose from are members of a class
and i cant declare a function pointer and then assign it to a member of that specific class
(ex . fncpty = &class.function). Any other ideas about it?

For handling the signal i use the signal function which takes signal and a function pointer, any alternatives to that either are welcomed.
Thanks in advance.

Paul McKenzie
March 28th, 2008, 02:10 PM
The problem here is that these functions i want to choose from are members of a classand i cant declare a function pointer and then assign it to a member of that specific class(ex . fncpty = &class.function). Any other ideas about it?When dealing with a non-static member function, the correct terminology to use is object, not class. The reason why this is important is because a non-static member function needs an object to work with, not a class.

See this FAQ:

http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.2

Regards,

Paul McKenzie

Richard.J
March 28th, 2008, 04:15 PM
and the signal handling has no notion of objects, so I doubt you'll find a solution that works. Handling signals is more about function calls in exceptional cases when in C++ you would choose to throw an exception.