Is CArray best for this...
- From: "GT" <ContactGT_remove_@xxxxxxxxxxx>
- Date: Wed, 16 Jan 2008 14:53:51 -0000
I am running into serious problems with CArray and beginning to wonder if
there is a better storage mechanism. I didn't know to define an operator=
originally (previous post), but have that all sorted now and application is
running, but with memory problems...
3 classes involved - ModelData, Category, Object
My ModelData class has a CArray of Category instances and each Category
instance has a CArray list of Object instances. Amongst the int and CString
member variables, one of the member variables on the Object class is a
pointer back up to the containing Category object.
My test application creates a series of Category instances and after
creating each Category, 5 Object instances are created and stored inside
that category (in the CArray). At creation time, the object instances store
away a pointer to the Category instance and that pointer is never changed
again in my code. After creating the 3rd Category instanceall is well and
the Object's pointers in the first 3 categories correctly point to the
Category object, but as soon as I create a 4th Category instance and
populate it, the Object's pointers in the first 3 categories are corrupted
and turn into bad_ptrs.
I don't change these pointers after they are originally setup. I therefore
presume that the Category being pointing is getting moved in memory when the
CArray object is re-sized or changed in some way. Does this sound possible?
Is there a way of storing a safe pointer in my Object instance so that they
don't keep getting lost!
Is there a better way to store this information in my application?
.
- Follow-Ups:
- Re: Is CArray best for this...
- From: Joseph M . Newcomer
- Re: Is CArray best for this...
- From: AliR \(VC++ MVP\)
- Re: Is CArray best for this...
- Prev by Date: Re: Owner draw repaint
- Next by Date: Re: Owner draw repaint
- Previous by thread: How to disable a menu
- Next by thread: Re: Is CArray best for this...
- Index(es):
Relevant Pages
|
Loading