3 ms·
As far as the C++98 standard library goes I think vectors are by far the most useful construct it provides because they're like arrays but manage memory for you
by tgflynn 14y ago
As far as the C++98 standard library goes I think vectors are by far the most useful construct it provides because they're like arrays but manage memory for you.
Lot's of people prefer printf to cout/cin.
Iterators in my opinion are a bad idea because there are so many cases when you need to do index arithmetic. The idea of having common interfaces for data structures with very different performance characteristics is one that probably seemed great to some people at the time but it doesn't work too well in practice.
The C++11 standard library seems to have a lot more features that may be very useful, like regular expressions, but I haven't started using it yet and if you care about cross-platform code it probably won't be truly useable for several years.
EDIT: Had a nagging feeling I was forgetting something when I wrote this. Yes of course std::map is incredibly useful it's definitely something one would need to implement if it weren't in the library.
- pcowans 14y agoAlthough I kind of agree with you that iterators for vectors aren't really very necessary, for std::list, std::map, etc. I think they're quite a sensible way of sequentially accessing the data - you'd pretty much have to re-implement them if they didn't exist. In the case of maps, I don't actually think the container implementation is specified enough to allow you to get away with any less abstraction - it technically doesn't have to be a BST, although I guess you could argue that the containers should have mapped to precisely defined data structures in the first place. C++11's type inference does make STL iterators a lot less ugly, by the way. Also (referring to the initial post), there's no reason you have to use for rather than while when using iterators (while(v != c.end()) ...).