Talk:Delete (C++)

using the wrong delete is a vulnerability
The last paragraph is too hairy, I don't want too touch it, but it should explain that using the wrong delete is a security vulnerability, linking to: http://replay.web.archive.org/20080703153358/http://taossa.com/index.php/2007/01/03/attacking-delete-and-delete-in-c —Preceding unsigned comment added by 99.224.97.6 (talk) 18:00, 14 May 2011 (UTC)

NULL vs. 0
I recently made an edit to initialize pointers in the code snippets with  instead of 0. The "edit summary" field was insufficient for explaining my justification for doing so and several previous edits changed NULL to 0 with the following vague and nebulous justifications:

"'int *p_var = NULL' is still valid C++ syntax, but is very C-style, making it equal zero is more C++"

"Changed NULL to 0, although null is same as 0, it should be avoided."

Frankly, neither of these are good reasons. is no less "C++ style" (whatever that is) than, the   operator, or. And there is no indication as to why  should be avoided. The only reason to avoid using   is, as Bjarne Stroustrup explains, to avoid macros whenever possible (http://www.stroustrup.com/bs_faq2.html#null). However, this rational is purely a matter of personal preference and  is part of the C++ standard. Using  instead of 0 produces more self-documenting code (i.e., when manipulating a pointer value, setting it to   indicates to a human reader that the variable is a pointer without needing to reference the declaration). This is driven home by the fact that C++11 defines  (of course, if you're writing to the C++11 standard,   would be much preferred to  ). Also, if you're using the GCC C++ compiler (I don't know about other compilers)  is   which means the compiler will always understand the rvalue to be a pointer value (http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt02ch04s03.html). 71.65.94.23 (talk) 03:45, 26 October 2012 (UTC)