class ClientListener : public IClientListener
{
public:
ClientListener(IClientListenerEx ^ pListener)
{
//pListener为C#对象,我怎么用变量保存它
}
private:
IClientListenerEx ^ m_pListener;//在C++中直接定义此变量有错
}
class ClientListener : public IClientListener
{
public:
ClientListener(IClientListenerEx ^ pListener)
{
gcrootpTmp = new gcroot(pListener);
m_pListener = static_cast<void>(pTmp);
}
~ClientListener()
{
if (m_pListener)
{
gcrootpTmp = static_cast>(m_pListener);
delete pTmp;
m_pListener = NULL;
}
}
void Call(int code)
{
gcrootpTmp = static_cast>(m_pListener);
((IClientListenerEx ^)*pTmp)->OnStatusChanged(code);
}
private:
void* m_pListener;
}
有人可以指导一下吗?