紫黄水晶的功效与作用:关于VC++编译出现错误的问题,请高手帮忙

来源:百度文库 编辑:高考问答 时间:2024/05/08 11:52:00
class CStudentInfo : public CObject
{private:
CString strName;
CString strNo;
BOOL bMale;
CTime tBirth;
CString strSpecial;
DECLARE_SERIAL(CStudentInfo)

public:
CStudentInfo(){};
CStudentInfo(CString name,CString id,BOOL male,CTime birth,CString special);
void Serialize(CArchive &ar);
void Display(int y,CDC *pDC);
}

以上是"StudentInfo.h"文件

以下是"StudentInfo.cpp"文件
#include "stdafx.h"
#include "StudentInfo.h"
CStudentInfo::CStudentInfo(CString name,CString id,BOOL male,CTime birth,CString special)
{

//我在visual c++6.0建立了关于学生信息的可序列化结构,但在运行时在现在这个位置产生以下错误,
//不知道怎么改,还请各位高手帮忙
//E:\c\Student2\StudentInfo.cpp(4) : error C2533: 'CStudentInfo::CStudentInfo' : constructors not allowed a return type

strName =name;
strNo =id;
bMale =male;
tBirth =birth;
strSpecial =special;
}
void CStudentInfo::Display(int y,CDC*pDC)
{CString str,strSex("女");
if(bMale) strSex="男";
str.Format("%s %s %s %s %s",strName,strNo,strSex,tBirth.Format("%Y-%m-%d"),strSpecial);
pDC->TextOut(0,y,str);
}
IMPLEMENT_SERIAL(CStudentInfo,CObject,1)
void CStudentInfo::Serialize(CArchive &ar)
{if(ar.IsStoring())
ar<<strName<<strNo<<bMale<<tBirth<<strSpecial;
else
ar>>strName>>strNo>>bMale>>tBirth>>strSpecial;
}

去掉前面的:
CStudentInfo(){};