说明:
A类中调用B类的OnDead
A类中调用B类的OnDead
B类中调用A类的func
IA.h 文件
class IANotify
{
public:
virtual void OnDead() = 0;
};
class IA
{
virtual void func() = 0;
};
/*创建IA对象*/ IA* CreateA(IANotify* pNotify);
A.h 文件
#include "IA.h"
class A
: public IA
{
IANotify* m_pNotify;
virtual void func();
}
A.cpp 文件
#include "A.h"
IA* CreateA(IANotify* pNotify)
{
return new A(pNotify);
}
void A::func();
{
m_pNotify->OnDead(); //call B::OnDead
}
B.h 文件
#include "IA.h"
class B
: public IANotify
{
virtual void OnDead();
}