部分代码:
char * a=new char[100];
string * p1,* p2;
p1=new (a) string("test1");
p2=new (a) string("test2");
cout<<p1<<endl;
cout<<p2<<endl;
运行结果:
test1
test2
问:
1.为什么说p2没有收到new运算符返回的地址?
2.既然没有收到地址那为什么可以正常输出?
部分代码:
char * a=new char[100];
string * p1,* p2;
p1=new (a) string("test1");
p2=new (a) string("test2");
cout<<p1<<endl;
cout<<p2<<endl;
运行结果:
test1
test2
问:
1.为什么说p2没有收到new运算符返回的地址?
2.既然没有收到地址那为什么可以正常输出?