每调用一次函数,输出加1 c++ 实现
#include<iostream>
using namespace std;
int PlusOne(){
static int i = 1;
return i++;
}
int main(){
cout << "first call" << endl;
cout << PlusOne() << endl;
cout << "second call" << endl;
cout << PlusOne() << endl;
cout << "third call" << endl;
cout << PlusOne() << endl;
system("pause");
return 0;
}