1. 程式人生 > >[C++] 單例

[C++] 單例

ClassName *instance(QObject *parent = nullptr)
{
    static ClassName *instance = nullptr;
    if (instance == nullptr)
        instance = new ClassName();
    return instance;
}