helios wrote: |
---|
f you think phrases like "arrays are like vectors" aren't complete nonsense, you probably don't need C++, since the code you produce will be no faster than if you had written it in a higher level language. |
std::sort() over a vector is many times faster than qsort() over an array (granted, it's not array's fault, it's the function pointers that murder performance in C).
arrays are built-in while STL containers are not |
The first program people learn in either language relies on the library components for I/O. Unless you're writing a parser for C++, studying the library cannot be an afterthought.
How are they disconnected? |
non-copyable/movable/returnable, unlike the rest of the containers (unless wrapped in structs)
confusing to the beginners due to array-to-pointer conversion (which other containers don't have), so much so that people equate them with pointers.
size-unaware (dynamic array only), which means the programmers have to drag along another piece of information everywhere they take the array, which leads to "pointer + size" style of programming, while in C++ you would rather have "pointer + pointer"
size is part of the type (non-dynamic arrays only), and can't be accessed the same way as the size of other containers.
allocator-unaware (dynamic array only), that's a deal-breaker for me in particular (we don't use new, we have too many different kinds of memory -- how I have to drag around pointer, size, and the allocator object? I might as well write my own vector)
what am I saying, dynamic arrays aren't even accessible and have no names, can't be referenced, and the language bends over backwards with special rules for the pointers to their first elements.
(until C++11 for non-dynamic) non-swappable
(until C++11 for non-dynamic) unusable in generic programming because there was no common way to obtain iterators or value type from arrays that would also work with the rest of the containers.