缺少类型说明符是什么意思啊????
#include <iostream>int main()
{using namespace std;
int sum={0};
int getsum();
sum =getsum();
cout<<"Get 1-100 sum="<<sum<<endl;
}
int getsum()
{
static tmp=0;//报错行//
int flag=1;
for(flag=1;flag<100;flag++)
{tmp+=flag;}
return tmp;
}
: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int 领鱼币 改成 static int tmp=0; 或 static auto tmp=0; 应该是 static int tmp = 0 吧 static int tmp; 改成这样:
#include <iostream>
int main()
{
using namespace std;
int sum = {0};
int getsum();
sum = getsum();
cout << "Get 1-100 sum=" << sum << endl;
}
int getsum()
{
static int tmp = 0; //报错行//
int flag = 1;
for (flag = 1; flag < 100; flag++)
{
tmp += flag;
}
return tmp;
}
#include <iostream>
int main()
{using namespace std;
int sum={0};
int getsum();
sum =getsum();
cout<<"Get 1-100 sum="<<sum<<endl;
}
int getsum()
{
static int tmp=0;//报错行//
int flag=1;
for(flag=1;flag<100;flag++)
{tmp+=flag;}
return tmp;
} 有一说一,没看懂你搞个static干什么
页:
[1]