C++静态成员变量退出析构
#include <iostream> #include <memory> #include <Windows.h> using namespace std; class A { public: A(){ cout << "create" << endl; } ~A(){ cout << "delete" << endl; } }; class B { public: B() {}; ~B(){}; private: static std::shared_ptr<A> m_instance; }; std::shared_ptr<A> B::m_instance = std::shared_ptr<A>(new A()); int main() { B b; cout << "end" << endl; return 0; }
虽然如此,但是 chromium 还是报错
加no_destructor可以解决这个
https://www.cnblogs.com/wuOverflow/p/4636064.html