Path: utzoo!mnetor!uunet!mcvax!targon!wim
From: wim@targon.UUCP (Wim C. J. van Eerdt)
Newsgroups: comp.lang.c++
Subject: Now a bug (?)
Message-ID: <370@targon.UUCP>
Date: 15 Dec 87 15:53:13 GMT
Reply-To: wim@targon.UUCP (Wim C. J. van Eerdt)
Organization: Nixdorf Computer BV., OSP, P.O. Box 29,Vianen, The Netherlands
Lines: 61

Here is another file, that I have got from my colleague:
Gerard van Dorth.
When you want to contact him you can write to:
	Gerard van Dorth
	Nixdorf Computer BV.
	Department: EG4
	Postbus 29
	4130 EA  Vianen
	The Netherlands
Voice: +31 3473 75154
E-mail: No direct contact. (I promise to forward a printed version of your
mail to him.)
Here it goes!

------------------------------------------------------------------------
Subject:  Now a bug (?)

#include 


class	string  {

	char	*s;
	int	n;

   public:

	string();
	string( char*   );
	string( string& );

	friend ostream& operator<< ( ostream&, string& );

} ;


// ...


const string	text = "text";

void	call()
{

	cout << text;	// reference to a const object.

}


	A colleague typed the exhibited program and found an error on line
		cout << text;
The message is correct: the 2nd argument of operator<< is a reference to a
string. So he changed the definition into
		friend ostream& operator<< ( ostream&, string );
Surprise, that did not work either: the constructor string( string& ) still
takes the reference of the constant object. Neither skipping the constructor
nor skipping the cont declaration is the answer, who knows the answer.
-- 
	Wim van Eerdt                   E-mail: mcvax!targon!wim
	OSP, Nixdorf Computer Bv, Postbus 29, 4130 EA Vianen
	Nederland. Tel.: +31 3473 62211.