シングルトンの正しい使い方
class Hoge
{
private:
static Hoge instance;
Hoge():x(0){};
~Hoge(){};
Hoge( const Hoge& );
Hoge& operator = ( const Hoge& rhs );
private:
int x;
public:
static Hoge* getInstance(){ return &instance; }
void move()
{
Hoge::getInstance()->x += 100;
}
// ↑みたいな関数がいっぱい.
};
int main()
{
Hoge::getInstance()->move();
return 0;
}
まだコメントがありません。最初にコメントを残しませんか?