nofuck.cpp
1 #include <map> 2 3 static std::map<int, int> m; 4 5 std::map<int, int>& GetMap() 6 { 7 return m; 8 }
main.cpp
1 #include <map> 2 3 std::map<int, int>& GetMap(); 4 5 class Fuck{ 6 public: 7 Fuck(){ 8 GetMap().clear(); 9 } 10 }; 11 12 static Fuck fuck; 13 14 int main(int argc, char** argv) 15 { 16 return 0; 17 }
http://stackoverflow.com/questions/1005685/c-static-initialization-order
http://coolshell.cn/articles/10115.html
时间: 2024-10-14 23:01:14