Following this tutorial, http://msdn.microsoft.com/en-us/library/vstudio/3bfsbt0t.aspx I implement this code:
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;
}
}
then I call:
CFile file(_T("file.and"), CFile::modeCreate);
CArchive afr(&file, CArchive::store);
Esame e;
afr << e;
but i get << operator no operator found which takes a left-hand of type cArchive