local static object demo

来源:互联网 发布:网上贷款软件排行 编辑:程序博客网 时间:2024/06/06 06:29
#include <iostream>using namespace std;size_t foo();int main(){    for (size_t ix = 0; ix != 5; ++ix)        cout << foo() << " times called." << endl;    return 0;}size_t foo(){    static size_t counter = 0;    return ++counter;}

0 0
原创粉丝点击