Path: utzoo!mnetor!uunet!munnari!natmlab!basser!metro!otc!mikem From: mikem@otc.oz (Mike Mowbray) Newsgroups: comp.lang.c++ Subject: Re: Now a bug (?) Message-ID: <300@otc.oz> Date: 27 Dec 87 05:41:19 GMT References: <370@targon.UUCP> Organization: OTC Development Unit, Australia Lines: 31 In article <370@targon.UUCP>, Gerard van Dorth says: > A colleague typed the exhibited program and found an error on line > cout << text; Removing the const declaration of text will work, as will changing the friend function in class string to: friend ostream &operator<<(ostream&, string const &); > ... 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. I don't think the problem has anything to do with the ctor. Rather, the attempt to pass a const string to a function expecting an ordinary one is what cfront is complaining about. This is correct. Note that if you adopt the second solution above you'll need to ensure that the operator<< function doesn't attempt to modify the string, or more errors will then be produced. Mike Mowbray Systems Development |||| OTC || ACSnet: mikem@otc.oz UUCP: {uunet,mcvax}!otc.oz!mikem Phone: (02) 287-4104 Snail: GPO Box 7000, Sydney 2001, Australia