Pointer to member functions in VS C++ 2003

Joined
Jul 13, 2007
Messages
1
Reaction score
0
I have this code:

typedef void (*DevRespPointer) (BlueDevice __gc*);

class InternalBlueManager : public CBtIf
{
public:
DevRespPointer DeviceRespondedDelegate;

InternalBlueManager(void)
{
}

~InternalBlueManager(void)
{
}

//Implementacion de Funciones Virtuales Heredadas

void OnDeviceResponded (BD_ADDR bda, DEV_CLASS devClass, BD_NAME bdName, BOOL bConnected)
{

if (DeviceRespondedDelegate!=0)
{
BlueDevice *bd = new BlueDevice(bda, devClass, bdName);
DeviceRespondedDelegate(bd);
}
}

};


/////////////////////////////////////////////


public __gc class BlueManager
{

private: //Miembros Privados
InternalBlueManager * blue;


public: // Funciones Publicas

BlueManager(void)
{
blue = new InternalBlueManager();

}

~BlueManager(void)
{

}

void SetDelegates()
{
blue->DeviceRespondedDelegate = OnDeviceResponded;
}

private: //Funciones Privadas

void OnDeviceResponded(BlueDevice __gc *device)
{
// Do Something;
}

};


If I compile this I get this error message on the red line:
error C2440: '=' : cannot convert from 'void (__clrcall BlueClasses::BlueManager::* )(BlueClasses::BlueDevice __gc *)' to 'BlueClasses:: DevRespPointer'


If I change the red line for
blue->DeviceRespondedDelegate = &OnDeviceResponded;
I get this error:
error C2276: '&' : illegal operation on bound member function expression

If I change it for
blue->DeviceRespondedDelegate = &BlueManager:: OnDeviceResponded;
I get this error:
error C3374: managed function 'BlueClasses::BlueManager:: OnDeviceResponded' requires argument list.

And if I change it for
blue->DeviceRespondedDelegate = &(BlueManager:: OnDeviceResponded);
I get this error again:
error C2276: '&' : illegal operation on bound member function expression.

I'm compiling it with Visual Studio 2003, Framework 1.1

I've tried all what I have seen on forums and manuals and it doesn't work. Somebody knows what am I doing wrond? and, how can I solve it?

Ferenck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,073
Messages
2,570,539
Members
47,197
Latest member
NDTShavonn

Latest Threads

Top