#include <iostream>
using namespace std;
int f1(int a)
{
int b=0;
static int c=2;
cout<<"c的值是"<<c<<endl;
b++;
c++;
return a+b+c;
}
int main()
{
int a=2;
cout<<f1(a)<<endl;//这里输出6
cout<<f1(a)<<endl;//这里输出7,这是为什么呢?
}
因为输出第一行的时候c=3了,执行第二行,c=3不是等于2了,c++=4,返回2+1+4,输出就是7了
static可以参考
https://blog.csdn.net/guotianqing/article/details/79828100