
14 Sep
2006
14 Sep
'06
5:28 a.m.
Marshall Clow wrote:
At 9:06 PM -0700 9/13/06, Scott Meyers wrote: [ snip ]
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; std::string s;
Just a nit - I think that your third example is not like the others. A std::string, AFAIK, constructed with the default constructor, is perfectly valid - just empty.
In each case, a default constructor is invoked. They're all valid objects that presumably fulfill their invariants, it's just that you can't safely invoke very many operations on them. On the string s, for example, invoking size is fine, but invoking operator[] is not fine at all. Scott