derived class member function pointer

This is a discussion on derived class member function pointer within the C++ Programming forums, part of the General Programming Boards category; is it possible to in the baseclass declare a function-pointer that will point to a function in the derived class? ...

  1. #1
    btq
    btq is offline
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161

    derived class member function pointer

    is it possible to in the baseclass declare a function-pointer that
    will point to a function in the derived class?

    like:
    Code:
    class base {
        void (base::*ptrToFunction)();
    }
    
    class derived : public base {
        void doSomething();
        derived(){ptrToFunction=doSomething;};
    }
    now offcourse I get an "cannot convert from 'void (__thiscall derive::*)()' to 'void (__thiscall base::*)()" error but
    is there a way to accomplish this?

    thanks
    /btqq
    ...viewlexx - julie lexx

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    Read this.
    Code:
    #include <ip.hpp>

  3. #3
    btq
    btq is offline
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161
    word up!!
    exactly what I'm doing...
    thanks..!

    /btq

    (sorry for not noticed this one in my search )
    ...viewlexx - julie lexx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  3. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  4. Is it possible to have callback function as a class member?
    By Aidman in forum Windows Programming
    Replies: 11
    Last Post: 08-01-2003, 11:45 AM
  5. casting a void* to a pointer to a member function
    By Sebastiani in forum C++ Programming
    Replies: 13
    Last Post: 10-15-2002, 08:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21