按照本教程, http: //msdn.microsoft.com/en-us/library/vstudio/3bfsbt0t.aspx我实现了这个代码:
class Esame: public CObject
{
public:
INT voto;
INT crediti;
BOOL lode;
CString nome;
Esame(){}
Esame(CString nome, INT voto, BOOL lode, INT crediti) :nome(nome), voto(voto), lode (lode), crediti(crediti) {}
void Serialize(CArchive& ar);
protected:
DECLARE_SERIAL(Esame)
};
IMPLEMENT_SERIAL(Esame, CObject, 1)
void Esame::Serialize(CArchive& ar){
CObject::Serialize(ar);
if (ar.IsStoring())
{
ar << voto << lode << crediti;
}
else
{
ar >> voto >> lode >> crediti;
}
}
然后我打电话:
CFile file(_T("file.and"), CFile::modeCreate);
CArchive afr(&file, CArchive::store);
Esame e;
afr << e;
但我得到 << operator no operator found 它采用 cArchive 类型的左手