
15 Sep
2006
15 Sep
'06
4:09 p.m.
Scott Meyers wrote:
I'll note that C++ itself allows "uninitialized" objects with constructors to be created all the time:
std::ofstream ofs; std::vector<int>::iterator i;
The only time I have found it useful to have default-constructed objects that are otherwise unusable is when I need to store them in a map or other container that requires a default constructible object. That allows me to use the easier operator[] syntax instead of using insert and find. However, I've begun to view that as a defect in the interface of std::map rather than a need to have default constructible objects even when they are not usable. David