Horstmann’s C++ pitfalls tackles an interesting point when talking about streams. To quote him:
Use conversion to
void*
, not conversion toint
orbool
, to implement objects yielding truth values. Unlikeint
orbool
,void*
have no legal operations other than==
comparison.
As a programmer, I would be puzzled if some function returned void*
when I expect a boolean. Horstmann provides an example where using a void*
instead of a bool
seems appropriate. Is it always advisable?