SingleTon_Pattern - 8BitsCoding/RobotMentor GitHub Wiki

SingleTon은 쉽기에 바로 코드로 설명


class System {
private:
    System instance;
    System();

public:
    static System getInstance() {
        if(instance == null) {
            instane = new System();
        }

        return instance;
    }
}
int main()
{
    // System * ss = new System();
    // Compile Error

    System * ss = ss.getInstance();
    System * ss2 = ss.getInstance();
}

참고사이트