程序摘要如下:(各位高手帮我看看出错原因,分我会再追加,谢谢您)
struct ELEMENT //申明结构体
{
float x; //点的横坐标
float y; //点的纵坐标
int id; //点的ID
};
struct AREA //申明结构体
{
int count;
int list[60];
};
……
void CMy1014View::OnButtonJs()
{
// TODO: Add your control notification handler code here
extern int num;
while(!m_pSet->IsEOF ())
{
m_pSet->MoveNext();
m_pSet->GetRecordCount(); //num为数据库中记录的数目
}
num=m_pSet->GetRecordCount();
……
ELEMENT all[num]; //定义了结构体数组,每个结构体是一个点 (210)
for(int l=0;l<num;l++)
{
all[l].x=a1[l];
all[l].y=a2[l];
all[l].id=id[l];
} //结构体数组初始化
……
void CMy1014View::OnDraw(CDC* pDC)
{
// TODO: Add your specialized code here and/or call the base class
CMy1014Doc *pDoc=GetDocument();
ASSERT_VALID(pDoc);
const int x0=40,y0=20,x1=540,y1=380; //定义视图坐标
const int N=4,dx=(x1-x0)/N,h=dx/4; //数据的个数、条图的宽度以及侧面的宽度
const int M=30,dy=30; //等高线的间隔数及间隔宽度 int XS[N];
XS[0]=(int)(area[0].count/num)*100; (270)
XS[1]=(int)(area[1].count/num)*100;
XS[2]=(int)(area[2].count/num)*100;
XS[3]=(int)(area[3].count/num)*100; //演示数据
……
}
出错的地方:
E:\学习用资料\mypro\1014\1014View.cpp(210) : error C2057: expected constant expression
E:\学习用资料\mypro\1014\1014View.cpp(210) : error C2466: cannot allocate an array of constant size 0
E:\学习用资料\mypro\1014\1014View.cpp(210) : error C2133: 'all' : unknown size
E:\学习用资料\mypro\1014\1014View.cpp(270) : error C2065: 'area' : undeclared identifier
E:\学习用资料\mypro\1014\1014View.cpp(270) : error C2109: subscript requires array or pointer type
E:\学习用资料\mypro\1014\1014View.cpp(270) : error C2228: left of '.count' must have class/struct/union type
E:\学习用资料\mypro\1014\1014View.cpp(270) : error C2065: 'num' : undeclared identifier
struct ELEMENT //申明结构体
{
float x; //点的横坐标
float y; //点的纵坐标
int id; //点的ID
};
struct AREA //申明结构体
{
int count;
int list[60];
};
……
void CMy1014View::OnButtonJs()
{
// TODO: Add your control notification handler code here
extern int num;
while(!m_pSet->IsEOF ())
{
m_pSet->MoveNext();
m_pSet->GetRecordCount(); //num为数据库中记录的数目
}
num=m_pSet->GetRecordCount();
……
ELEMENT all[num]; //定义了结构体数组,每个结构体是一个点 (210)
for(int l=0;l<num;l++)
{
all[l].x=a1[l];
all[l].y=a2[l];
all[l].id=id[l];
} //结构体数组初始化
……
void CMy1014View::OnDraw(CDC* pDC)
{
// TODO: Add your specialized code here and/or call the base class
CMy1014Doc *pDoc=GetDocument();
ASSERT_VALID(pDoc);
const int x0=40,y0=20,x1=540,y1=380; //定义视图坐标
const int N=4,dx=(x1-x0)/N,h=dx/4; //数据的个数、条图的宽度以及侧面的宽度
const int M=30,dy=30; //等高线的间隔数及间隔宽度 int XS[N];
XS[0]=(int)(area[0].count/num)*100; (270)
XS[1]=(int)(area[1].count/num)*100;
XS[2]=(int)(area[2].count/num)*100;
XS[3]=(int)(area[3].count/num)*100; //演示数据
……
}
出错的地方:
E:\学习用资料\mypro\1014\1014View.cpp(210) : error C2057: expected constant expression
E:\学习用资料\mypro\1014\1014View.cpp(210) : error C2466: cannot allocate an array of constant size 0
E:\学习用资料\mypro\1014\1014View.cpp(210) : error C2133: 'all' : unknown size
E:\学习用资料\mypro\1014\1014View.cpp(270) : error C2065: 'area' : undeclared identifier
E:\学习用资料\mypro\1014\1014View.cpp(270) : error C2109: subscript requires array or pointer type
E:\学习用资料\mypro\1014\1014View.cpp(270) : error C2228: left of '.count' must have class/struct/union type
E:\学习用资料\mypro\1014\1014View.cpp(270) : error C2065: 'num' : undeclared identifier
在文件的开始处直接int num=0;