#include <iostream>
#include <new>
#include <cstdlib>
using namespace std;
int main()
{
char* buf = new char[sizeof(string)]; // 分配空间
string* pstr = new(buf) string( "abc "); // 在所给空间上应用构造函数创建对象
//cout < <buf;
cout < <*pstr;
system( "pause ");
}
#include <new>
#include <cstdlib>
using namespace std;
int main()
{
char* buf = new char[sizeof(string)]; // 分配空间
string* pstr = new(buf) string( "abc "); // 在所给空间上应用构造函数创建对象
//cout < <buf;
cout < <*pstr;
system( "pause ");
}