No match for 'operator<<' in '((HttpRequest*
Dear advanced c/g++ programers:
I have a simple program from book C++ cookbook, page 291, 8.3, Using
Constructors and Destructors to manage
resources (or RAII), but it can not get compiled in my g++
-------
// Example 8-3. Using constructors and destructors
#include <iostream>
#include <string>
using namespace std;
class Socket {
public:
Socket(const string& hostname) {}
};
class HttpRequest {
public:
HttpRequest (const string& hostname) :
sock_(new Socket(hostname)) {}
void send(string soapMsg) {sock_ << soapMsg; }
~HttpRequest () {delete sock_;}
private:
Socket* sock_;
};
void sendMyData(string soapMsg, string host) {
HttpRequest req(host);
req.
// Nothing to do here, because when req goes out of scope
// everything is cleaned up.
}
int main() {
string s = "xml";
sendMyData(s, "www.oreilly.com");
}
-------
my test compile fail as
-------
eric@eric-
Example8-3.cpp: In member function ‘void
HttpRequest:
Example8-
‘((HttpRequest*
-------
on both g++ 4.3.4(cygwin on windown xp) and 4.5.2(ubuntu10.04)
you can get its source code from
http://
to test by yourself
looking and thanks your help a lot in advance, Eric
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Edward Benson for more information if necessary.