Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!ukc!warwick!rafter From: rafter@warwick.UUCP (Mark Rafter) Newsgroups: net.lang.c++ Subject: partial solution to cout << 'a' producing 97 Message-ID: <449@ubu.warwick.UUCP> Date: Wed, 15-Oct-86 12:15:48 EDT Article-I.D.: ubu.449 Posted: Wed Oct 15 12:15:48 1986 Date-Received: Fri, 17-Oct-86 23:50:50 EDT Reply-To: rafter@ubu.UUCP (Mark Rafter) Organization: Computer Science, Warwick University, UK Lines: 29 If you add the following (Steve Rumsby's idea): ostream& put(char); // put('a') writes a ostream& operator<<(const char &c){ return this->put(c);} to the class ostream BEFORE the declaration of the operator ostream& operator<<(int a) { return *this< main() { char b = 'b'; cout << char('a') << b; } will output ``ab'' rather than ``9798''. However there are the following (related) quirks: 1 the order of the declarations is important 2 the new << operator must be a member of ostream I cannot find any justification for these two points in the C++ book - is there any? ---------------------------------- Mark Rafter, Computer Science, Warwick Univ, Coventry CV4 7AL, ENGLAND ..!ukc!warwick!rafter +44 203 523364