CObjArray allocation/deallocation 
Author Message
 CObjArray allocation/deallocation

When using a CObjArray, do I need to explicitely allocate (new) and
deallocate (delete) when growing and shrinking the array?

--
Thanks,
Mike Ober.



Sat, 05 Jun 2004 22:05:28 GMT  
 CObjArray allocation/deallocation
yes and no.  You need to new and delete the objects you put into the array, but
not the array itself.


Sat, 05 Jun 2004 22:24:28 GMT  
 CObjArray allocation/deallocation
Thanks.  I assume I will also need a obj.Copy operator to make this work.
This is a new area for MFC for me, which is why I ask.

Mike Ober.



Quote:
> yes and no.  You need to new and delete the objects you put into the
array, but
> not the array itself.



Sun, 06 Jun 2004 02:13:34 GMT  
 CObjArray allocation/deallocation
no, you don't need a copy constructor.  The CObjArray stores pointers to the
original objects, not copies.


Sun, 06 Jun 2004 03:17:42 GMT  
 CObjArray allocation/deallocation


Wed, 18 Jun 1902 08:00:00 GMT  
 CObjArray allocation/deallocation
For objects use CTypedPtrArray which is preferable by MS , they state
CObArray as old and  CTypedPtrArray  as new somewhere in 1995 or before :) .
Arkady



Quote:
> Thanks.  I assume I will also need a obj.Copy operator to make this work.
> This is a new area for MFC for me, which is why I ask.

> Mike Ober.



> > yes and no.  You need to new and delete the objects you put into the
> array, but
> > not the array itself.



Sun, 06 Jun 2004 15:55:04 GMT  
 CObjArray allocation/deallocation


Wed, 18 Jun 1902 08:00:00 GMT  
 CObjArray allocation/deallocation
Thanks, that will make life easier.
--
Mike Ober.



Quote:
> no, you don't need a copy constructor.  The CObjArray stores pointers to
the
> original objects, not copies.



Sun, 06 Jun 2004 22:04:14 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Allocation and deallocation of exceptions...

2. repeated allocation and deallocation

3. allocation/deallocation warnings in splint

4. Question regarding memory allocation/deallocation

5. memory allocation/deallocation for tree (a prelimary summary)

6. Strange memory allocation and deallocation errors:

7. Memory Allocation and DeAllocation (new and free) !?

8. Heap Allocation/Deallocation in a DLL

9. DLL Memory Allocation and Deallocation

10. returning CObjArray in function?

11. finding a CObject in a CObjArray

12. Memory allocation/deallocation for tree? Any good way?

 

 
Powered by phpBB® Forum Software