6.1.1 局部对象-局部静态对象
作者:互联网
书中页数:P185
代码名称:count-calls.cc
#include <cstddef>
using std::size_t;
#include <iostream>
using std::cout; using std::endl;
size_t count_calls()
{
static size_t ctr = 0; // value will persist across calls
return ++ctr;
}
int main()
{
for (size_t i = 0; i != 10; ++i)
cout << count_calls() << endl;
return 0;
}
标签:std,cout,calls,对象,局部,6.1,using,include,size 来源: https://blog.csdn.net/qit1314/article/details/90137072