I have followed all the rules in the online help for deriving a class from CObject. When a use the >> and << operators in my DOC class, I get a compiler error C2679 : binary '<<' : no operator defined which takes a right-hand operand of type 'class CBitmapFile' (or there is no acceptable conversion).

Here is my CBitmapFile header

class CBitmapFile : public CObject
{
DECLARE_SERIAL( CBitmapFile )

private:
BITMAPFILEHEADER bmfh;
BITMAPINFO bmi;
LPVOID ptrPixels;
CString fname;
int error;

public:
CBitmapFile();
~CBitmapFile();

virtual void Serialize( CArchive& ar );

int Width() { return (int)bmi.bmiHeader.biWidth; }
int Height() { return (int)bmi.bmiHeader.biHeight; }

int GetError( CString *pstrError = NULL );

void Empty();
void DrawBitmap( CDC *pDC, int sf );
};

and here is part of the CPP file

#include "stdafx.h"
#include "bmfile.h"

IMPLEMENT_SERIAL( CBitmapFile, CObject, 1 )

CBitmapFile::CBitmapFile()
{
ptrPixels = NULL; // make sure the pointer is NULL
Empty(); // make an empty bitmap
}

now why can't I do this in my Doc class

void CMyDoc::Serialize( CArchive& ar )
{
if( ar.IsLoading())
ar >> bmf;
else
ar << bmf;
}