[ fromfile: memoryaccess.xml id: arrays2 ]
Arrays of primitive types, such as int
, char
, and byte
are used to implement caches.
Arrays of objects are supported in the C++ language for backward compatibility with C's arrays of struct
s, but are used only for uniform collections of identical structures, rather than collections of similar polymorphic objects.
If you need random access to the stored items, QList (from Qt) or vector
(from STL) can be used instead of an array.
Both are implemented using dynamic arrays under the covers.
It is preferable to use such containers rather than arrays whenever possible, because containers correctly and safely allocate and free memory for you.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |