????γ???????????? new ???????????
???????????? ???????[ 2016/5/10 13:40:15 ] ??????????????????? .NET
????1. ????
??????????????????????windows????????????????????????????????δ?????????????o????????????????????????????????
struct sample
{
int* ptr_table[4][4];
//... other members
};
void test()
{
sample* sample_ptr = new sample[10];
for (int i = 0; i < 4; i++)
sample_ptr[0].ptr_table[0][i] = new int(i);
// ?????????????????????sample_ptr?????е??????и?????????????е?????г????????;
int* int_ptr = sample_ptr[0].ptr_table[0][0];
if (int_ptr != NULL)
{
printf("ptr1 = 0x%x
"?? int_ptr);
*int_ptr = 100;
}
int_ptr = sample_ptr[1].ptr_table[0][0];
if (int_ptr != NULL)
{
printf("ptr2 = 0x%x
"?? int_ptr);
*int_ptr = 100; // crashed here!
}
}
??????sample* sample_ptr = new sample[10]???и??sample* sample_ptr = new sample[10]()??????????е?????????????????????????檔
????????????????
????(1) ???????????(new sample[10])?????????±??????????????????????????????????????????????
????(2) new sample[10]??new sample[10]()??????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11