See More

// // Created by zhangrongxiang on 2017/9/12. // #include #include "static.h" // 函数声明 void func(void); static int count = 10; /* 全局变量 */ int staticDemo() { while (count--) { func(); } return 0; } // 函数定义 void func(void) { static int i = 5; // 局部静态变量 i++; std::cout << "变量 i 为 " << i; std::cout << " , 变量 count 为 " << count << std::endl; }