DELETE数组和指针问题,有没有办法处理
睿音 2006-11-21 03:41:11 在bcb5.0中,我在不同的if语句里定义了2个相同的数组,具体如下:
if(x=1)
{
int temp[20];
/...
.../
delete[] temp;
}
if(y=2)
{
int temp[20];
/...
.../
delete[] temp;
}
/...
.../
当条件语句同时运行很少时,比如只是x=1,y=2时,系统并不会报错误.如果当这样的程序多了以后,bcb系统会提示Access violation at address 41004bbe in module ''BORLNDMM.DLL'.返回程序后提示问题出现在delete[] temp;上.我猜想可能是因为系统回收内存问题.不知道如何才能解决.不希望在每个if中定义不同的数组.
希望各位大侠指点下.