ccArtermices
一道关于c++内存分配的问题

首先编译器没有报告语法错误

#include *本站禁止HTML标签噢*

#include *本站禁止HTML标签噢*

#include *本站禁止HTML标签噢*

using namespace std;

void main()

{

allocator *本站禁止HTML标签噢* alloc;

auto const p=alloc.allocate(10);

auto q=p;

string s;

do

{

getline(cin,s);

alloc.construct(q++,s);

}

while(s!="");

while(q!=p)cout<<*q++<<endl;

while(q!=p)alloc.destroy(--q);

alloc.deallocate(p,10);

while(cin.get()!='q');

}

然后编译器报错:

0x0F416D26 (msvcp110d.dll) (using_allocate.exe 中)处有未经处理的异常: 0xC0000005: 读取位置 0xCDCDCDCD 时发生访问冲突。

到底出什么错了?应该怎么改?

求大神指导,谢谢~