【MFC求助】定义返回值为对象指针的函数出现错误
张大伟 2012-06-24 02:44:16 按照教程写的单文档程序,出现了问题,核对半天也找不到哪里不对了
这是声明,在doc类中
CMyLine * GetLine(int index);
定义:
CMyLine * CHelloword6Doc::GetLine(int index)
{
if (index<0||index>m_ObArray.GetUpperBound())
return 0;
else
return(CMyLine * m_ObArray -> GetAt(index));
}
class CMyLine:public CObject //声明直线类CMyLine
{
protected:
int m_StartX; //直线起点的X坐标
int m_StartY; //直线起点的Y坐标
int m_EndX; //直线终点的X坐标
int m_EndY; //直线终点的Y坐标
public:
CMyLine(int StartX,int StartY,int EndX,int EndY); //直线的构造函数
void DrawLine(CDC *pDc); //用来在视图中绘制直线
};
报错大多指向函数的声明:
>d:\vc++2010\helloword6\helloword6\helloword6doc.h(54): error C2143: 语法错误 : 缺少“;”(在“*”的前面)
1>d:\vc++2010\helloword6\helloword6\helloword6doc.h(54): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\vc++2010\helloword6\helloword6\helloword6doc.h(54): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\vc++2010\helloword6\helloword6\helloword6doc.h(54): warning C4183: “GetLine”: 缺少返回类型;假定为返回“int”的成员函数