如果我從最初分配空間的位置刪除不同函數中的存儲空間,是否會得到未定義的行爲?C++從不同的函數中刪除存儲空間與分配空間的位置不同
typedef struct {
unsigned int Data1;
unsigned int Data2;
unsigned int Data3;
}TData;
void CreateStorage(void)
{
TData *TempData = new TData;
DeleteStorage((unsigned char*)TempData);
}
void DeleteStorage(unsigned char *StorageToDelete)
{
delete (TData*)StorageToDelete;
}
否.............. – JosephH 2012-01-07 01:34:17