D
danip
Hi,
I used to have the following:
class CArchive
{
public:
// create and specify the filename to use
CArchive(CString filename, DWORD size);
virtual ~CArchive();
CArchive& operator<<(bool b);
CArchive& operator<<(BYTE by);
CArchive& operator<<(WORD w);
CArchive& operator<<(LONG l);
CArchive& operator<<(DWORD dw);
CArchive& operator<<(float f);
CArchive& operator<<(double d);
CArchive& operator<<(int i);
CArchive& operator<<(short w);
CArchive& operator<<(char ch);
CArchive& operator<<(unsigned u);
CArchive& operator<<(const CString& s);
};
//template function to write array to the archive
template <class ARCHIVE, class ARRAY>
ARCHIVE& ArchiveAddArray(ARCHIVE& archive, const ARRAY& array)
{
int nSize = array.GetSize();
archive << nSize;
for(int n=0; n< nSize; n++)
{
archive << array[n];
}
return archive;
}
struct BBLStruct
{
CString m_str1;
CString m_str2;
CString m_str3;
};
class CBBLstructArray : public CArray<BBLStruct, BBLStruct&>
{
};
class CArchiveEx : public CArchive
{
public:
CArchiveEx(CString filename, DWORD size)
: CArchive(filename, size) {}
virtual ~CArchiveEx() {}
CArchiveEx& operator<<(CBBLstructArray& BBLs)
{ return ArchiveExAddArray(*this,BBLs); }
};
template <class ARRAY>
CArchiveEx& ArchiveExAddArray(CArchiveEx& self, const ARRAY& array)
{
ArchiveAddArray(self, array);
return self;
}
in VC++ 6.0 and everything worked okay.
I'm now moving to VC 7.1 and I receive the following error:
error C2678: binary '<<' : no operator found which takes a left-hand
operand of type 'CArchiveEx' (or there is no acceptable conversion)
When I delete the method:
CArchiveEx& operator<<(CBBLstructArray& BBLs)
{ return ArchiveExAddArray(*this,BBLs); }
everything is okay.
What changed in templates in VC 7.1 ? and solutions ?
Thanks
-- Dani
I used to have the following:
class CArchive
{
public:
// create and specify the filename to use
CArchive(CString filename, DWORD size);
virtual ~CArchive();
CArchive& operator<<(bool b);
CArchive& operator<<(BYTE by);
CArchive& operator<<(WORD w);
CArchive& operator<<(LONG l);
CArchive& operator<<(DWORD dw);
CArchive& operator<<(float f);
CArchive& operator<<(double d);
CArchive& operator<<(int i);
CArchive& operator<<(short w);
CArchive& operator<<(char ch);
CArchive& operator<<(unsigned u);
CArchive& operator<<(const CString& s);
};
//template function to write array to the archive
template <class ARCHIVE, class ARRAY>
ARCHIVE& ArchiveAddArray(ARCHIVE& archive, const ARRAY& array)
{
int nSize = array.GetSize();
archive << nSize;
for(int n=0; n< nSize; n++)
{
archive << array[n];
}
return archive;
}
struct BBLStruct
{
CString m_str1;
CString m_str2;
CString m_str3;
};
class CBBLstructArray : public CArray<BBLStruct, BBLStruct&>
{
};
class CArchiveEx : public CArchive
{
public:
CArchiveEx(CString filename, DWORD size)
: CArchive(filename, size) {}
virtual ~CArchiveEx() {}
CArchiveEx& operator<<(CBBLstructArray& BBLs)
{ return ArchiveExAddArray(*this,BBLs); }
};
template <class ARRAY>
CArchiveEx& ArchiveExAddArray(CArchiveEx& self, const ARRAY& array)
{
ArchiveAddArray(self, array);
return self;
}
in VC++ 6.0 and everything worked okay.
I'm now moving to VC 7.1 and I receive the following error:
error C2678: binary '<<' : no operator found which takes a left-hand
operand of type 'CArchiveEx' (or there is no acceptable conversion)
When I delete the method:
CArchiveEx& operator<<(CBBLstructArray& BBLs)
{ return ArchiveExAddArray(*this,BBLs); }
everything is okay.
What changed in templates in VC 7.1 ? and solutions ?
Thanks
-- Dani