Here is what I've copied from MSDN about new operator:
The
newoperator cannot be used to allocate a function, but it can be used to allocate pointers to functions. The following example allocates and then frees an array of seven pointers to functions that return integers.int (**p) () = new (int (*[7]) ()); delete *p;
Well there is nothing strange with first line, it allocates an array of pointers to functions, but I just don't understand how the second deletes that array? I think it should be:
delete[] *p;
Can anyone explain this?
delete[] p(no asterisk).*pin this case is 0 (i.e. NULL), thereforedelete *pis a no-op. If you had initialized the first element of the array to point to a function, the behavior of the program would have been undefined (it would have probably crash your program).