Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: No match for 'operator<<' in '((HttpRequest* Date: Thu, 14 Jul 2011 17:55:57 +1200 Lines: 37 Message-ID: <987ep7F78bU4@mid.individual.net> References: <2a9f24c1-ac62-4d44-b518-e30a9877fc13@f39g2000prb.googlegroups.com> <9871f3F78bU1@mid.individual.net> <987bd9F78bU3@mid.individual.net> <87eabda8-9f12-40e4-ac3e-f38101047a15@m5g2000prh.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 6BvfbyZx56mSwb8ekmYK2grekQdEMnWlGLgWB8FVAhF8pCFizz Cancel-Lock: sha1:k+Hsk2KiYIXFEQDT4ZpxG889338= User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 In-Reply-To: <87eabda8-9f12-40e4-ac3e-f38101047a15@m5g2000prh.googlegroups.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:7793 On 07/14/11 05:17 PM, eric wrote: > > ------------------------------------------------------------------------------------------------------------------ > If I tried my other design, put opearator<< in class Socket > --------------------------------------------------- > // Example 8-3. Using constructors and destructors > #include > #include > using namespace std; > class Socket { > public: > Socket(const string& hostname) {} > > ostream& operator<<(const std::string&) {} > }; > class HttpRequest: public Socket { Why is HttpRequest derived from Socket? > public: > HttpRequest (const string& hostname) : > sock_(new Socket(hostname)) {} > > // ostream& operator<<( Socket*, const std::string& ) {} This can't be a class member, declare it outside of the class and look at the return type (hint: where do you get an ostream to return?). > hope that help any advanced c/g++ program to debug my(actually > author's) program The original code is pretty smelly (and wouldn't compile), but you've made it worse! -- Ian Collins