退出程序时出现“access violation at address 0046d475 in module 'ss.exe' write of address
access violation at address 0046d475 in module 'ss.exe' write of address 00505850
DEBUG时没有此提示框。
RELEASE以后,在关闭程序时会跳出此框。我没法调试,在MAP里也定位不到00505850
谢谢谢谢谢谢,有人说是访问了已删除的资源,或者访问了空指针。
不知道怎么找找找
[解决办法]
如果这样定义,就会有问题 TButton *btn[16],这是在栈上定义数组,不需要delte 了
[解决办法]
如果一定要delete ,就这样
TButton **btn;
btn=new TButton *[16];
delete []btn;
[解决办法]
void __fastcall TForm4::Button2Click(TObject *Sender)
{
TButton *Btn[16]; //定了一,有16元素(16指),
//btn是量,函退出自放空
for (int i = 0; i < 16; i++)
{
Btn[i] = new TButton(this);
Btn[i]->Parent = this;
Btn[i]->Align = alBottom;
Btn[i]->Caption = String(i);
}
delete[] Btn;//有用new 分配存,就不需要delete了,多余的delete 造成不可知的果。
}
如 CppFile 所 用 TButton ** 或者 使用 std:vector<TButton *>
要弄清楚的地方: 多重指及其存分配的用法, 及量的生命期,
”delete[] Btn;//跟delete []btn;应该没有区别的吧“ //C/C++ 法很松,是有的。