Thread: derived class member function pointer

  1. #1
    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,708
    Read this.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    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, 03:07 AM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11: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