On Sep 30, 12:28 am, john <j...@no.spamwr ote:
In TC++PL 3, on page 616, "class basic_ios" has the public members
"operator void *() const; // nonzero if !fail()
bool operator!() const { return fail(); }"
for using them in conditional statements in the style:
if(cin) // if( !void *(0) )
if(!cin) // if( cin.operator!()
Why isn't operator bool() used instead? For historical
reasons?
The most obvious reason is that iostream was part of the
language before bool was. And that bool is an integral type,
which can lead to unexpected results when used with the >and
<< operators.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34