Re: No match for 'operator<<' in '((HttpRequest*
"eric" <cneric12lin0@gmail.com> ha scritto nel messaggio
news:a7286acf-941d-4c4c-a8ba-0103b63cd3a2@t38g2000prj.googlegroups.com...
On Jul 14, 1:24 am, "io_x" <a...@b.c.invalid> wrote:
=================================================
eric@eric-laptop:~/cppcookbook/ch8$ g++ Example8-3-2.cpp
Example8-3-2.cpp:14:2: error: #error "Non posso compilare con questo
sistema"
Example8-3-2.cpp:47:2: error: ?u32? does not name a type
Example8-3-2.cpp: In constructor ?Socket::Socket(std::string&)?:
Example8-3-2.cpp:37:24: error: invalid conversion from ?const char*?
to ?unsigned char*?
Example8-3-2.cpp:39:22: error: invalid conversion from ?unsigned
char*? to ?const char*?
Example8-3-2.cpp:39:22: error: initializing argument 1 of ?FILE*
fopen(const char*, const char*)?
Example8-3-2.cpp: At global scope:
Example8-3-2.cpp:61:1: error: ?u32? does not name a type
Example8-3-2.cpp: In function ?int main()?:
Example8-3-2.cpp:73:26: error: ?sendMyData? was not declared in this
scope
--------------------------------------------------------------------------------------------------->------
Thanks Io_x
and your suggestion
above is my compiler 's response of your test program. I will try to
learn more by myself. And at meantime,
I guess it is not difficult for you to refine it if you think it is
necessary so it can fit on my system too.
i forget one header... i'm not too much expert...
than i not use the C++ file way, but the C one
than i use macro all want i not to write i.e. P, G etc etc
desclaimer: it could be wrong;
here it just open a file of name "thisfile" and write in it just "xml"
there it could make burn your little pc
could be less danger if execute in a debugger one step at time
// Example 8-3. Using constructors and destructors
#include <stdio.h>
#include <limits.h>
#include <iostream>
#include <string>
#define u8 unsigned char
#if ULONG_MAX == 0xFFFFFFFF
#define u32 unsigned long
#elif UINT_MAX == 0xFFFFFFFF
#define u32 unsigned int
#elif USHRT_MAX == 0xFFFFFFFF
#define u32 unsigned short
#else
#define u32 unsigned long
#endif
#define uns unsigned
// macro for function
#define P printf
// macro for keyWords
#define G goto
#define R return
#define W while
#define F for
#define T template
#define TN typename
#define S sizeof
using namespace std;
class Socket{
public:
Socket(string& hostname)
{u8 *a=(u8*)hostname.c_str();
name="NOfile";
fsck = fopen( (const char*)a , "w+b" );
if(fsck!=0)
{name=hostname;}
}
~Socket()
{if( fclose(fsck)==-1 )
P("Errore on close file %s\n", name.c_str());
}
int send(string& soapMsg)
{size_t k, slen;
slen=soapMsg.length();
F(k=0; k<slen ; ++k)
if( fputc(soapMsg[k], fsck) == EOF ) break;
if(k!=slen) R -1;
R 0;
}
// here could be 2 file too and not just one
FILE* fsck;
string name;
};
int sendMyData(string soapMsg, string host) {
Socket req(host);
R req.send(soapMsg);
}
int main(void)
{string s="xml";
if(sendMyData(s, "thisfile")==-1)
P("ERROR\n");
else P("seems ok\n");
R 0;
}
of course, I always welcome whoever keep original class of book
authors expect, i.e. class HttpRequest
and its overloaded operator << in
void send(string soapMsg) {sock_ << soapMsg;}
to complete the fix
Eric
----------------------------------------------------------------------------------------------------------