CArray::Add causes a compiler error
Posted on 2004-11-18
I'm having some issues with the CArray class. It seems to be attempting to access a private member in CObject when I use the Add function. The error I get is
error C2248: 'CObject::operator`='' : cannot access private member declared in class 'CObject'
The error apparently occurs on line 529 of atlsimpstr.h, which is this function:
PCXSTR GetString() const throw()
return( m_pszData );
Anyways, the relevant code from the program is as follows:
typedef struct tagITEMMAP
CArray<tagITEMMAP, tagITEMMAP&> Children;
} ITEMMAP, *LPITEMMAP;
void Whatever(LPITEMMAP Item)
Temp.Parent = Item;
Temp.Index = Entries[Item->Index].FirstIndex;
When I compile the program I get the following error:
error C2248: 'CObject::CObject': cannot access private member declared in class 'CObject'
This error is caused by the line Item->Children.Add(Temp);
since when it is commented out the program compiles and runs fine.
I am using the beta of Visual Studio 2005 (8.0.40607.16), but the error occurs in 2003 as well.
Thanks in advance for any help.