首页 > 代码库 > c++----static 重复调用

c++----static 重复调用

class Base{public:    Base()    {        cout << "cons" << endl;    }    ~Base()    {        cout << "de" << endl;    }    static Base* Default()    {        static Base b;        return &b;    }};int main(int argc, char** argv){    for (int i = 0; i < 3; i++)    {        Base::Default();    }}

  只构造析构一次!

c++----static 重复调用