Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • 9
    With delete, the opposite is usually true -- if you delete an object, it doesn't get set to NULL, and then you attempt to call a method on it, you'll find that this != NULL, but it will likely crash or behave oddly if its memory has already been reclaimed for use by some other object. Commented Dec 4, 2009 at 0:19
  • 5
    delete might not always get an l-value though, consider delete this + 0; Commented Dec 4, 2009 at 0:31
  • 9
    Visual Studio 6 was released in June 1998. The C++ standard was published in September. OK, so Microsoft could have anticipated the standard, but in principle it is not surprising that many pre-standard compilers do not implement the standard ;-) Commented Dec 4, 2009 at 1:12
  • 4
    Just for fun, here is a nice article about MFC and it's use of if (this == 0) viva64.com/en/b/0226 Commented Jan 3, 2016 at 16:44
  • 7
    Note that MFC is a bit of a special case because it was never really intended to be used with anything other than VC++, and because the teams were in contact, the MFC team could rely on implementation details like this (and ensure that they'll be around for as long as needed, and behave exactly as desired). Since this behavior is not otherwise documented or guaranteed even for VC++, third-party libraries cannot rely on it. Commented Jan 3, 2016 at 20:57