Ryan Bullock

class member function pointers

Discussion created by Ryan Bullock on Mar 7, 2007
Latest reply on Mar 13, 2007 by CompilerGuru
the following code compiles but i goto the wrong address actually another function instead of assigned :smileysad:
this is just a knock up of the actually class but should be the only applicable code?
Caffeine cant help me anymore what goes on here enlighten me please respected freescale community members.
*EDIT* something of note... i am using the HC12 micro / CW 4.5
whilst debugging i found that the function func() in this case sits at 0xF2BED8 all good the address loaded into the CB variable is 0xBED8F2 (offset 0 , index -1) is this a complier error? notice that LSByte should be MSByte or does it interrupt a pointer differently to a function pointer ?
class Foo; //fwd declaration
typedef void (Foo::*Callback)(UINT16);
class Foo //declaration proper
Callback CB;
void somefunction();
void somethingelse();
void func(UINT16);
static Foo foo;
Foo Foo::foo;
func(0); //dummy call to stop compiler "optimising" function out
void Foo::somefunction()
CB = &Foo::func(); //assign addr
void Foo::somethingelse()
this->*CB(7); //call with param ?

Message Edited by CaffineCoder on 2007-03-0710:07 PM

Message Edited by CaffineCoder on 2007-03-0710:16 PM

Alban Edited message following user request via abuse link

Message Edited by Alban on 2007-03-08 09:11 AM