帮忙看看我的程序。非常感谢
你好,我先用winzard建立一个单文档的摸板,我自己建一个myData.h代码如下:
#ifndef _INSIDE_VISUAL_CPP_STUDENT
#define _INSIDE_VISUAL_CPP_STUDENT
class CStudent : public CObject
{
DECLARE_SERIAL(CStudent)
public:
CString m_strName;
int m_nGrade;
CStudent()
{
m_nGrade = 0;
}
CStudent( const char* szName, int nGrade) : m_strName(szName)
{
m_nGrade = nGrade;
}
CStudent(const CStudent& s) : m_strName(s.m_strName)
{
// copy constructor
m_nGrade = s.m_nGrade;
}
const CStudent& operator =(const CStudent& s)
{
if(this==&s)
return *this;
else
{
m_strName = s.m_strName;
m_nGrade = s.m_nGrade;
return *this;
}
}
BOOL operator ==(const CStudent& s) const
{
if ((m_strName == s.m_strName) && (m_nGrade == s.m_nGrade)) {
return TRUE;
}
else {
return FALSE;
}
}
BOOL operator !=(const CStudent& s) const
{
// Let抯 make use of the operator we just defined!
return !(*this == s);
}
virtual void Serialize(CArchive& ar);
#ifdef _DEBUG
void Dump(CDumpContext& dc) const;
#endif // _DEBUG
};
//typedef CTypedPtrList<CObList,CStudent*> CStudentList;
typedef CTypedPtrList<CObList,CSudent *>CStudentList;
#endif // _INSIDE_VISUAL_CPP_STUDENT
然后再建一个MyData.cpp文件
代码如下:
#include "stdafx.h"
#include "CData.h"
IMPLEMENT_SERIAL(CStudent, CObject, 0)
void CStudent::Serialize(CArchive& ar)
{
TRACE("Entering CStudent::Serialize\n");
if(ar.IsStoring())
{
ar << m_strName << m_nGrade;
}
else {
ar >> m_strName >> m_nGrade;
}
}
#ifdef _DEBUG
void CStudent::Dump(CDumpContext& dc) const
{
CObject::Dump(dc);
dc << "m_strName = " << m_strName << "\nm_nGrade = " << m_nGrade;
}
#endif // _DEBUG
始终编译不过。显示错误
e:\vc\cdata.h(66) : error C2143: syntax error : missing ';' before '<'
e:\vc\cdata.h(66) : error C2143: syntax error : missing ';' before '<'
说丢了;号但我明明写了的啊。
谢谢各位.