æè¿ããã£ã¨æèãã¦ãããã¨ã
static HogeManager hogeManager_;
ã§ã¯ãªãã
namespace {
HogeManager hogeManager_;
}
ã¨ããã
HogeManagerã¯éçã§ããããããã§ã¯ãªãã
ãã¡ã¤ã«å
ã¢ã¯ã»ã¹ããããã ãã«éããªãããæ£å½ãªæ©è½ã§ããç¡ååå空éã使ãã
ï¼Cã ã¨staticã«ããããããªããã©ï¼
Hoge* hoge = HogeManager::getInstance()->create(...);
ã§ã¯ãªãã
Hoge* hoge = ::CreateHoge(..);
ã使ãã
Hogeãã¤ããããã«ã
HogeManagerã®ã¤ã³ã¹ã¿ã³ã¹ãã°ãã¼ãã«ã«ããå¿
è¦ã¯ãªãã
é¢æ°ã§ååã
ã°ãã¼ãã«é¢æ°ã¯æªã§ã¯ãªããã
ã°ãã¼ãã«å¤æ°ã¯æªã ãã¨ããç念ã«å¾ãã°ããã¯å½ç¶ã®çã¨ãªãã
CreateHogeã®ä¸èº«ã¯ã
namespase {
HogeManager hogeManager_;
}
Hoge* CreateHoge(...)
{
return hogeManager_.create(...);
}
ã ã£ããããå¯è½æ§ã¯é«ããã
éçãããç¡åãã°ãã¼ãã«ã¤ã³ã¹ã¿ã³ã¹ãããã°ãã¼ãã«é¢æ°ãã ã¨æã£ã¦ãã