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