|
The CObArray |
The CObArray
The CObArray class supports arrays of CObject pointers. These object arrays are similar to C arrays, but they can dynamically shrink and grow as necessary. Under Win32, the size of a CObArray object is limited only to available memory.
CObArray incorporates the IMPLEMENT_SERIAL macro to support serialization and dumping of its elements. If an array of CObject pointers is stored to an archive, either with the overloaded insertion operator or with the Serialize member function, each CObject element is, in turn, serialized along with its array index.
Note Before using an array, use SetSize to establish its size and allocate memory for it. If you do not use SetSize, adding elements to your array causes it to be frequently reallocated and copied. Frequent reallocation and copying are inefficient and can fragment memory.
Note You must use the IMPLEMENT_SERIAL macro in the implementation of your derived class if you intend to serialize the array.
结:其也支持串行化,也就是其内的元素可以被保存到磁盘文件中,功能和Document文档内保存数据一样,都可通过Serivalize(CArchive &ar)来保存相关对象的指针,具体的数据由保存的对象也能过串行化来进行保持.所以CObArray对象也就只有在文档中的Servialize()中去调用它本身的Servialize(),因只有这样子,框架才会自动地去调用要被保存对象的Servialize()函数,从而保存了数据. | |
|
|
|
|