May 10th, 1999, 03:58 AM
Platform:Windows95,VC++6.0[SP2]
Hi,
I am facing a strange problem in the usage of Serialize function of CObject.
I have a few CObject derived class pointers as member variable in the file classes that needs to read data from the serialized files.
CMyClass* m_pMy, CLstClass* m_pLst, CTstClass* m_pTst, all derived from CObject which need to be read from my serialized file.
When I use the ar>>m_pMy operator to read the CMyClass object I get the compiler error C2679"binary 'operator' : no operator defined which takes a right-hand operand of type 'CMyClass' (or there is no acceptable conversion)".
NOTE:However I don't get the error for ar>>m_pLst and ar>>m_pTst.
As a get around way if I read the data into a CObject object and then typecast it to my object it works fine.
void CMyfile::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar<<m_pMy;
ar<<m_pLst;
ar<<m_pTst;
}
else
{
// TODO: add loading code here
ar>>m_pMy/**Original Way which gave compiler error**/
ar<<m_pLst;
ar<<m_pTst;
/***Get around Way***/
/**New get around way to get rid of compiler error**/
CObject* pOb = NULL;
ar>>pOb;
m_pMy = (CMyClass*)pOb;
}
Can someone explain the reason behind this.
Thanks in advance
Ganga
Hi,
I am facing a strange problem in the usage of Serialize function of CObject.
I have a few CObject derived class pointers as member variable in the file classes that needs to read data from the serialized files.
CMyClass* m_pMy, CLstClass* m_pLst, CTstClass* m_pTst, all derived from CObject which need to be read from my serialized file.
When I use the ar>>m_pMy operator to read the CMyClass object I get the compiler error C2679"binary 'operator' : no operator defined which takes a right-hand operand of type 'CMyClass' (or there is no acceptable conversion)".
NOTE:However I don't get the error for ar>>m_pLst and ar>>m_pTst.
As a get around way if I read the data into a CObject object and then typecast it to my object it works fine.
void CMyfile::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar<<m_pMy;
ar<<m_pLst;
ar<<m_pTst;
}
else
{
// TODO: add loading code here
ar>>m_pMy/**Original Way which gave compiler error**/
ar<<m_pLst;
ar<<m_pTst;
/***Get around Way***/
/**New get around way to get rid of compiler error**/
CObject* pOb = NULL;
ar>>pOb;
m_pMy = (CMyClass*)pOb;
}
Can someone explain the reason behind this.
Thanks in advance
Ganga