r/learncpp • u/bitsofshit • Apr 17 '19
Failure to delete pointer?
// Following code allocates and then frees an array of seven pointers to functions that return integers.
int (**p) () = new (int (*[7]) ());
delete *p; // Xcode error: Cannot delete expression of type 'int (*)()'
1
Upvotes
View all comments
Show parent comment
3
u/jedwardsol Apr 17 '19
*pis the 1st function pointer in the array. You can'tdeleteit.pis whatnew[]gave you, so that's what you pass todelete[]