CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2007
    Posts
    36

    signal handling and function pointers.

    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.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: signal handling and function pointers.

    Quote Originally Posted by verbal
    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-lit....html#faq-33.2

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    May 2001
    Location
    Germany
    Posts
    1,158

    Re: signal handling and function pointers.

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured