基类CDraw的子类CPline中定义结构体:
typedef struct
{
float x;//顶点横坐标
float y;//顶点纵坐标
float z;
}PointStruct;//存储每个顶点坐标的结构
基类CDraw中定义:
BOOL PointRgn(float x,float y,int Numble,PointStruct *PointList,float blc);
此时在CDraw中应该如何声明PointStruct?
谢谢各位了!
如果在.h中定义
struct PointStruct *PointList;
提示错误
error C2036: 'struct PointStruct *' : unknown size
error C2027: use of undefined type 'PointStruct'
如果在.cpp中定义
CDraw::CDraw():struct PointStruct *PointList//无参数的构造函数
{
}
提示错误
error C2061: syntax error : identifier 'PointStruct'
: error C2061: syntax error : identifier 'PointStruct'
请问是为什么啊?
因为在CPline中用到了这个结构体
#include "Draw1.h"
typedef struct
{
float x;//顶点横坐标
float y;//顶点纵坐标
float z;
}PointStruct;//存储每个顶点坐标的结构
class CPline : public CDraw
{
protected:
int m_Numble; //连续直线或多边形区域的顶点数
PointStruct* m_PointList; //存储顶点的数组指针
float m_fLong;//连续直线的长度
public:
CPline(short ColorPen,short ColorBrush,float LineWide,
short LineType,short Layer,int id_only,BOOL Delete,
int Numble,PointStruct* PointList)
:CDraw(ColorPen,ColorBrush,LineWide,LineType,Layer,id_only,Delete)
{
m_Numble=Numble;//动态分配存储顶点坐标的结构数组
m_PointList=new PointStruct[Numble+1]; //分配空间
if(Numble>0) //如果顶点数目大于0
{
for(int i=0;i<Numble;i++)
m_PointList[i]=PointList[i];
}
}
CPline();
virtual ~CPline();
};
在CDraw中想用PointStruct就不知道怎么办了???