Path: utzoo!attcan!uunet!mcvax!hp4nl!kunivv1!atcmpe!leo From: leo@atcmp.nl (Leo Willems) Newsgroups: comp.lang.c++ Subject: istream conversion operator Keywords: istream conversion operator Message-ID: <522@atcmpe.atcmp.nl> Date: 24 May 89 18:38:21 GMT Organization: AT Computing, Nijmegen, The Netherlands Lines: 29 In: int i; while ( cin >> i) //... the expression ``cin >> i'' gives as result an istream&. That's the part I understand. This istream& (which represents an istream object) is converted using ``operator istream*() { return _eof < state ? 0 : this; }'' to give a value which can be used in a while expression My question is: Why does this conversion take place? There is no assignment involved (i.e. to a void*) from which the type system can decide which conversion is appropriate. The only explanation I can give is that class istream has only one conversion operator so there isn't much choise. 1) if my explanation is incorrect, then where did I go wrong 2) correct or not: the returning ``this'' from the conversion operator is a pointer, not a reference. Does is get converted somehow to a reference? Leo Willems Internet: leo@atcmp.nl AT Computing UUCP: mcvax!hp4nl!kunivv1!atcmpe!leo P. O. Box 1428 6501 BK Nijmegen The Netherlands