代码修改如下:
#include <iostream>
#include <string>
using namespace std;
struct Xml_Info
{
char *encoding;
char *version;
};
struct Http_Content
{
//char *content_length;
Xml_Info *xml_info;
//Xml_element *envelope;
};
struct Message
{
//Http_Header *http_header;
Http_Content *http_content;
};
class ProbeDecorator
{
public:
Message message;
void Init();
void GenSoap();
string soap, add;
};
void ProbeDecorator::Init()
{
Http_Content* http_content = new Http_Content;
Xml_Info* xml_info = new Xml_Info;
http_content->xml_info = xml_info;
this->message.http_content = http_content;
xml_info->version = new char[6];
memset(xml_info->version,0,6);
memcpy(xml_info->version,"1.0",3);
xml_info->encoding = new char[6];
memset(xml_info->encoding,0,6);
memcpy(xml_info->encoding,"utf-8",5);
cout << this->message.http_content->xml_info->version << endl;
cout << this->message.http_content->xml_info->encoding << endl;
}
void ProbeDecorator::GenSoap()
{
cout << this->message.http_content->xml_info->version << endl;
cout << this->message.http_content->xml_info->encoding << endl;
;
}//你看看我这样申请这样对么
int main()
{
ProbeDecorator c;
c.Init();
c.GenSoap();
return 0;
}