釋放typedef的數組,用delete還是delete[]

 typedef int scorers[LESSONS_NUM]

int    *pScorer    =    new    scorers;
delete    pScorers;    //Wrong!!!
delete[]    pScorers;    //Right


爲了避免這樣的錯誤,建議不要對數組類型typedef,或則採用STL中的vector代替數組。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章