プロジェクト A、PA.h :
#include "Common.h"
class PA
{
void func()
{
Common::getInstance()->cm();
Common::getInstance()->onlyCallByPA();
}
}
プロジェクト共通、Common.h :
class Common
{
SINGLETON
public:
void cm(){}
private:
//I do not want PB to call onlyCallByPA
//so I want to add class PA to friend class
//so I need to include PA.h
//but if I include PA.h, PB.cpp include PA.h
//this will make PA.h expose to PB
//I do not want PB to include PA.h
void onlyCallByPA(){}
}
プロジェクト B、PB.cpp :
#include "Common.h"
class PB
{
//I need to call cm() but PB do not be allowed to call onlyCallByPA
//and also do not be allowed to include PA.h
}
PA
だから私はasCommon
の友達クラスを作りたいのですが、これは への依存を導入しPB
ます。
より良い解決策はありますか?または、他のデザインを使用して必要なものを実装できますか?