That's because you're initialising it inside the class definition. That's only allowed for constant integral and enumeration types (always) and for constexpr
data members (since C++11). Normally, you'd initialise it where you define it (outside the class), like this:
Application.h
class Application {
private:
static Application* app;
}
Application.cpp
Application* Application::app = nullptr;
Note that you need to provide the out-of-class definition even in the constexpr
case, but it must not contain an initialiser then. Still, I believe the second case is what you actually want.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…