<?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[Gibt es die Möglichkeit *this auszugeben?]]></title><description><![CDATA[<p>Der *this eines Objektes zeigt ja immer auf sich selbst. Kann ich diesen *this auch irgendwie sichtbar machen, also ausgeben? Mit cout hatte ich kein Glück, der kann damit nix anfangen.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/309152/gibt-es-die-möglichkeit-this-auszugeben</link><generator>RSS for Node</generator><lastBuildDate>Wed, 05 Aug 2026 11:18:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/309152.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Oct 2012 15:06:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Gibt es die Möglichkeit *this auszugeben? on Mon, 15 Oct 2012 15:06:02 GMT]]></title><description><![CDATA[<p>Der *this eines Objektes zeigt ja immer auf sich selbst. Kann ich diesen *this auch irgendwie sichtbar machen, also ausgeben? Mit cout hatte ich kein Glück, der kann damit nix anfangen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2260743</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2260743</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 15 Oct 2012 15:06:02 GMT</pubDate></item><item><title><![CDATA[Reply to Gibt es die Möglichkeit *this auszugeben? on Mon, 15 Oct 2012 15:15:33 GMT]]></title><description><![CDATA[<p>Ich verstehe dein Problem nicht. Natürlich kannst du <code>*this</code> ausgeben, vorausgesetzt, dass eine entsprechende Überladung des <code>operator&lt;&lt;</code> existiert...</p>
<p>Eine Fehlermeldung wäre auch schön.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2260746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2260746</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Mon, 15 Oct 2012 15:15:33 GMT</pubDate></item><item><title><![CDATA[Reply to Gibt es die Möglichkeit *this auszugeben? on Mon, 15 Oct 2012 15:17:19 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<p>Ich verstehe dein Problem nicht. Natürlich kannst du <code>*this</code> ausgeben, vorausgesetzt, dass eine entsprechende Überladung des <code>operator&lt;&lt;</code> existiert...</p>
</blockquote>
<p>p0wned, h4x0r <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Butterbrot schrieb:</p>
<blockquote>
<p>Mit cout hatte ich kein Glück, der kann damit nix anfangen.</p>
</blockquote>
<p>Dann hast was falschgemacht.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

struct foo_t {
	void print_this() {
		std::cout &lt;&lt; this &lt;&lt; '\n';
	}
};

int main()
{
	foo_t foo;
	foo.print_this();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2260747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2260747</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Mon, 15 Oct 2012 15:17:19 GMT</pubDate></item><item><title><![CDATA[Reply to Gibt es die Möglichkeit *this auszugeben? on Mon, 15 Oct 2012 15:20:52 GMT]]></title><description><![CDATA[<p>edit: hier stand Müll ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2260748</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2260748</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 15 Oct 2012 15:20:52 GMT</pubDate></item><item><title><![CDATA[Reply to Gibt es die Möglichkeit *this auszugeben? on Mon, 15 Oct 2012 15:22:26 GMT]]></title><description><![CDATA[<p>Oh ja ich wollte *<strong>this</strong> ausgeben und habe <strong>this</strong> gar nicht probiert^^</p>
<p>Danke nun geht es.</p>
<p>EDIT: Es ging mir nur darum mit Kopiekonstruktor, Zuweisungoperator und so etwas rumzuspielen und mir anzugucken wann welche Objekte erzeugt werden. Achja jetzt kommt ja noch die Move-Geschichten dazu, das muss ich auch noch verinnerlichen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2260749</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2260749</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 15 Oct 2012 15:22:26 GMT</pubDate></item><item><title><![CDATA[Reply to Gibt es die Möglichkeit *this auszugeben? on Tue, 16 Oct 2012 07:19:33 GMT]]></title><description><![CDATA[<p>Swordfish schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#include &lt;iostream&gt;

struct foo_t {
	void print_this() {
		std::cout &lt;&lt; this &lt;&lt; '\n';
	}
};

int main()
{
	foo_t foo;
	foo.print_this();
}
</code></pre>
</blockquote>
<p>Besser mit const und cast auf void*, da die Ausgabe des Pointers überladen sein kann:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

struct foo_t {
    void print_this( std::ostream&amp; out ) const {
        out &lt;&lt; static_cast&lt; const void* &gt;( this );
    }
};

std::ostream&amp; operator&lt;&lt;( std::ostream&amp; out, const foo_t* p )
{
    return out &lt;&lt; &quot;foo_t*(&quot; &lt;&lt; static_cast&lt; const void* &gt;( p ) &lt;&lt; &quot;)&quot;;
}

int main()
{
    using std::cout;
    foo_t foo;
    foo.print_this( cout &lt;&lt; &quot;this: &quot; );
    cout &lt;&lt; &quot;\n&quot;;
    cout &lt;&lt; &quot;Pointer: &quot; &lt;&lt; &amp;foo &lt;&lt; &quot;\n&quot;;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2260884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2260884</guid><dc:creator><![CDATA[Besserwessi]]></dc:creator><pubDate>Tue, 16 Oct 2012 07:19:33 GMT</pubDate></item></channel></rss>