Thread: address of a member function

  1. #1
    Unregistered
    Guest

    address of a member function

    I need to get the address of a member function.I found out that it can't be done as usual ,i.e. using the function name as a pointer .
    But Turbo C++ 3.0 help tells me that it can be done like this:

    &ClassName::MemberFunction

    Bu it also states that member function pointers are not true pointer.I cannot use it as a pointer to a member function.

    The following is what i want to accomplish:

    class C
    {
    ......
    void interrupt far (*OldISR)(...);
    void interrupt far ISR(...);
    void func();
    }

    void C::func()
    {
    OldISR = getvect(INT_NO);
    setvect(INT_NO,&C::ISR);
    }

    But it simply doesn't work.
    How can i do that?

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    To properly take the address of a class member function, the function either needs to be static, or you need to take the address of using an instance of the class. Check the link below for more info -

    http://www.parashift.com/c++-faq-lit...o-members.html

  3. #3
    Unregistered
    Guest
    thanx

  4. #4
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Get the address fromt he *this pointer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Replies: 6
    Last Post: 04-27-2006, 10:55 AM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  5. Im so lost at . .
    By hermit in forum C Programming
    Replies: 18
    Last Post: 05-15-2002, 01:26 AM