[ fromfile: lists.xml id: introcontainers ]
In C++ arrays are regarded as evil.
Following are a few good reasons to avoid using arrays in C++:
Neither the compiler nor the runtime system checks array subscripts to make sure that they are within the correct range.
A programmer using an array has the responsibility to write extra code to do the range checking.
Inserting, prepending, or appending elements to an array can be expensive operations (in terms of both runtime and developer time).
std::list and QList are the most basic generic containers in their respective libraries.
They are similar to each other in interface (the way they are used from client code).
They differ in implementation (the way they behave at runtime).
Both libraries also provide several other generic containers that are optimized for particular types of application.
We used the term generic containers because
Generics are classes or functions that accept template (Section 11.1) parameters so that they can be used with different types of data.
Containers (Section 6.7) are objects that can contain other objects.
With a single function call, items can be added, removed, swapped, queried, cleared, moved, located, and counted in a variety of ways.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |