Problems using CArchive "<<" operator

Hi,

I get this compiler error message for the code below:
"error C2678: binary '<<' : no operator defined which takes a left-hand 
operand of type 'class CArchive' (or there is no acceptable conversion)". 

Whats wrong, the code is from a book about MFC?

void CLogHandler::StoreLog(CLogItem logItem)
{

   unsigned int nType =0,nMsgId=0;
   CFileException e;
   CFile fileArchiveFile;

   if (fileArchiveFile.Open(
      "C:/test3.txt", 
      CFile::modeReadWrite | 
      CFile::modeCreate| 
      CFile::modeNoTruncate, 
      &e))
   {
      CArchive arItemArchive (&fileArchiveFile, CArchive::store);
 
      arItemArchive << logItem.GetTime;
   }
   else
   {
      int error = e.ReportError(nType, nMsgId);
   }
}
0
Sebbie (9)
8/26/2004 6:33:07 AM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
861 Views

Similar Articles

[PageSpeed] 36

Sebbie wrote:

> Hi,
> 
> I get this compiler error message for the code below:
> "error C2678: binary '<<' : no operator defined which takes a left-hand 
> operand of type 'class CArchive' (or there is no acceptable conversion)". 
> 
> Whats wrong, the code is from a book about MFC?
> 
> void CLogHandler::StoreLog(CLogItem logItem)
> {
> 
>    unsigned int nType =0,nMsgId=0;
>    CFileException e;
>    CFile fileArchiveFile;
> 
>    if (fileArchiveFile.Open(
>       "C:/test3.txt", 
>       CFile::modeReadWrite | 
>       CFile::modeCreate| 
>       CFile::modeNoTruncate, 
>       &e))
>    {
>       CArchive arItemArchive (&fileArchiveFile, CArchive::store);
>  
>       arItemArchive << logItem.GetTime;
>    }
>    else
>    {
>       int error = e.ReportError(nType, nMsgId);
>    }
> }


If GetTime is a method then you left out the () after the method name.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
8/26/2004 12:34:08 PM
Reply:

Similar Artilces: