<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[this == NULL]]></title><description><![CDATA[<p>Hallo,</p>
<p>mehrere in MFC-Klassen gekapselte Methoden haben Abfragen der Art</p>
<pre><code class="language-cpp">if (this == NULL)
...
</code></pre>
<p>man findet diese Abfragen hauptsächlich (oder sogar nur?) in operator-Methoden oder Funktionen der Art GetSafe???.</p>
<p>Meine Frage:<br />
Wann kann der this-Zeiger denn eigentlich NULL sein?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/207587/this-null</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Apr 2026 15:08:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/207587.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 09 Mar 2008 16:10:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to this == NULL on Sun, 09 Mar 2008 16:10:17 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>mehrere in MFC-Klassen gekapselte Methoden haben Abfragen der Art</p>
<pre><code class="language-cpp">if (this == NULL)
...
</code></pre>
<p>man findet diese Abfragen hauptsächlich (oder sogar nur?) in operator-Methoden oder Funktionen der Art GetSafe???.</p>
<p>Meine Frage:<br />
Wann kann der this-Zeiger denn eigentlich NULL sein?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1471031</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1471031</guid><dc:creator><![CDATA[_interest]]></dc:creator><pubDate>Sun, 09 Mar 2008 16:10:17 GMT</pubDate></item><item><title><![CDATA[Reply to this == NULL on Sun, 09 Mar 2008 16:13:36 GMT]]></title><description><![CDATA[<p>((CKlasse*)(NULL))-&gt;Metthode();</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1471033</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1471033</guid><dc:creator><![CDATA[beispiel]]></dc:creator><pubDate>Sun, 09 Mar 2008 16:13:36 GMT</pubDate></item><item><title><![CDATA[Reply to this == NULL on Sun, 09 Mar 2008 18:05:01 GMT]]></title><description><![CDATA[<p>AFAIK sind ja auch Dinge erlaubt wie</p>
<pre><code class="language-cpp">class MySmartPtr
{
private:
    unsigned refcnt;

public:
    ...
    void removeRef (void)
    {
        if (--ref == 0)
            delete this;
    }
};
</code></pre>
<p>Vielleicht ergibt die Prüfung von this in diesem Zusammenhang Sinn. Ob jedoch grundsätzlich der Aufruf nichtvirtueller Methoden mit ungültigem this-Zeiger erlaubt ist, weiß ich nicht - diese Freiheit wird sich Microsoft wohl einfach genommen haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1471094</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1471094</guid><dc:creator><![CDATA[audacia]]></dc:creator><pubDate>Sun, 09 Mar 2008 18:05:01 GMT</pubDate></item><item><title><![CDATA[Reply to this == NULL on Sun, 09 Mar 2008 18:15:12 GMT]]></title><description><![CDATA[<p>audacia schrieb:</p>
<blockquote>
<pre><code class="language-cpp">delete this;
</code></pre>
</blockquote>
<p>Damit wird this aber nicht zu NULL und</p>
<pre><code class="language-cpp">this = NULL;
</code></pre>
<p>ist auch nicht ohne Schummelei möglich.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1471098</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1471098</guid><dc:creator><![CDATA[funky cat]]></dc:creator><pubDate>Sun, 09 Mar 2008 18:15:12 GMT</pubDate></item><item><title><![CDATA[Reply to this == NULL on Sun, 09 Mar 2008 18:48:51 GMT]]></title><description><![CDATA[<p>_interest schrieb:</p>
<blockquote>
<p>mehrere in MFC-Klassen gekapselte Methoden haben Abfragen der Art</p>
<pre><code class="language-cpp">if (this == NULL)
</code></pre>
</blockquote>
<p>Beispiele! Ich habe keine gefunden...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1471113</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1471113</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 09 Mar 2008 18:48:51 GMT</pubDate></item><item><title><![CDATA[Reply to this == NULL on Sun, 09 Mar 2008 19:00:00 GMT]]></title><description><![CDATA[<p>GetSafeHwnd() macht das z.B.!<br />
Dito in den Gdi Objekt Klassen.</p>
<p>Der Vorteil liegt auf der Hand. Auch für einen CWnd* NULL Zeiger liefert pWnd-&gt;GetSafeHwnd() immer NULL ohne zu crashen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1471117</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1471117</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Sun, 09 Mar 2008 19:00:00 GMT</pubDate></item><item><title><![CDATA[Reply to this == NULL on Sun, 09 Mar 2008 19:25:05 GMT]]></title><description><![CDATA[<p>Achso, somit werden also bequeme quick-n-dirty-Lösungen wie</p>
<pre><code class="language-cpp">m_pMyWnd-&gt;GetParent ()-&gt;GetSafeHandle ()
</code></pre>
<p>etc. möglich.</p>
<p>Cool!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1471123</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1471123</guid><dc:creator><![CDATA[_interest]]></dc:creator><pubDate>Sun, 09 Mar 2008 19:25:05 GMT</pubDate></item><item><title><![CDATA[Reply to this == NULL on Mon, 10 Mar 2008 08:27:57 GMT]]></title><description><![CDATA[<p>Das funktioniert nur wenn m_pMyWnd gültig ist.</p>
<p>GetSafeHabdle ist IMHO keine CWnd Methode!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1471268</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1471268</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 10 Mar 2008 08:27:57 GMT</pubDate></item></channel></rss>