Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CArray error

Status
Not open for further replies.

MarcoMB

Programmer
Oct 24, 2006
61
IT
I've an error and i can't understand the reason...i've an app that serialize
elements organized in records of a my-class type that contain input data from
user in a CFormView.
So if i put those records in a CObArray the serialization of the array and
related class elements contained it's ok, but if i use a CArray it's going in
this error

_AFX_INLINE CStringData* CString::GetData() const
{ ASSERT(m_pchData != NULL); return ((CStringData*)m_pchData)-1; }

Can someone know the reason?
i defined
CObArray m_oaName and it's ok
CArray <myclass*,myclass*> m_oaName and it's going wrong

so i add dinamically object to array
CMyClass *pclass = new CMyClass();
and call serialize method of array
m_oaName.Serialize(ar)
that calls the related Serialize function in CMyClass that create the CFile
object using the ar reference with the related variables value.So i create
array of pointers to objects created dinamically and located in other memory
space.But what should difer by using CObArray or CArray with specifing
CMyClass* pointer like object ?
So i say it again it works fine only with CObArray...
the only thing i can think to solve the problem is implementing a
SerializeElements function for CArray template class...what do u think?
 
MarcoMB,

Th reason this is not working for you is because CArray supports collections of objects of any type and not object pointers.

If you want to store object pointers in a template collection class you need to use CTypedPtrArray.

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top