You cannot store function pointers to class methods.  You must declare your
function as static.  That will fix the compilation error.


"Chris Apers" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Hi,
>
> I have i little problem and perhaps you can help.
> In the following exemple, i'd like to call
> func1, func2 or func3  with _func depending of the configuration
> of the app, so i call setfunc(int) to set the _func value.
> But i have the following error :
>
> --|   illegal implicit convertion from 'void (B::*)()' to 'void (*)()'.
>
> I know my typedef declaration is wrong but i can find how to declare it.
>
> thanks
> ------------------
> class A {
> ...
> };
>
> class B : public A {
> public :
>     void setfunc(int);
>     void funcexec();
>
>     ...
>
> private:
>     typedef void ExecProc(void)
>     ExecProc *_func;
>
>     void func1();
>     void func2();
>     void func3();
>
> };
>
> void B::setfunc(int what) {
>
>     switch (what) {
>         case 1:
>             _func = func1;
>             break;
>
>         case 2:
>             _func = func2;
>             break;
>
>         case 3:
>             _func = func3;
>             break;
>     }
>
> }
>
> void B::funcexec() {
>
>     _func();
> }
>
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to