Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!bu.edu!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!news.funet.fi!funic!santra!santra!Ari.Huttunen From: Ari.Huttunen@hut.fi (Ari Juhani Huttunen) Newsgroups: comp.lang.c++ Subject: Re: possible to overload << and pass an object ptr? Message-ID: Date: 26 Mar 91 09:32:50 GMT References: <1991Mar24.074308.28666@kestrel.edu> <1991Mar25.192002.6392@kestrel.edu> Sender: news@santra.uucp (Cnews - USENET news system) Organization: Helsinki University of Technology, Finland Lines: 17 In-Reply-To: gyro@kestrel.edu's message of 25 Mar 91 19:20:02 GMT In article <1991Mar25.192002.6392@kestrel.edu> gyro@kestrel.edu (Scott Layson) writes: Ari>How about this one? Ari> Ari>struct S { Ari>friend void operator<<(S *s, char p1) { *s << p1; } Ari> void operator<<(char p1) { cout << p1; } Ari>}; Scott>Ah. Indeed that works for the specific example under consideration. No, this does not work. Or at least it does not work with g++ 1.37.1. The error is: operator has no user-defined argument type (meaning the friend operator.) Though I think this _should_ work. -- Ari Huttunen, email: Ari.Huttunen@hut.fi, phone: 90-7285944