struct Rv
{
static int rv[1024];
static int bh;
static int bt;
}
1.少个";"
2."static"哪有这么用的,什么目的?什么意图?编译都通不过.跟什么初始化什么其他毫无关系.
应改为:
struct Rv
{
int rv[1024];
int bh;
int bt;
};
When modifying a variable, the static keyword specifies that the variable has static duration (it is allocated when the program begins and deallocated when the program ends) and initializes it to 0 unless another value is specified.
你的rv,bh,bt有没有初始化?因为它们是静态变量,你必须初始化它们。
比如:
#include<iostream.h>
struct Vr
{
static int rv[1024];
static int bh;
static int bt;
};
int Vr::rv[1024]={1,2,2,2};//初始化
int Vr::bh=3;//初始化
int Vr::bt=4;//初始化
int main()
{
cout<<"try!";
return 0;
}
luxyi:
struct Rv
{
static int rv[1024];
static int bh;
static int bt;
};
已经是定义了。
另外我试了一下
#include<iostream.h>
int main()
{
struct Vr
{
static int rv[1024];
static int bh;
static int bt;
};
cout<<"try!";
return 0;
}
编译出错。
error C2246: 'rv' : illegal static data member in locally defined class