//the setup
tiles = new Tile **[num_bands];
for(int i = 0 ; i < num_bands ; i++)
tiles[i] = new Tile *[num_spokes];
for(int i=0; i < num_bands; i++){
for(int ii=0; ii < num_spokes; ii++){
tiles[i][ii] = 0;
}
}
//the problem
delete tiles[1][1];
當我刪除一個圖塊時,圖塊[1] [1]仍然保存着一個地址。我認爲它應該是一個空指針或0x0,但它不是。我刪除這個錯誤嗎?什麼是刪除數組中指針的正確方法?
正確的方法是在內部使用'std :: vector>'並在其周圍包裹一些薄的二維數組外殼。 –
sbi
2010-07-05 22:00:18