<?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 oder type::]]></title><description><![CDATA[<p>Oh ich hab jetzt herausgefunden, dass man sowas machen kann:</p>
<pre><code>class base
{
    public:
    int a;
};

class erbe: public base
{
    public:
    int a;

    int foo()
    {
        int a;

        a=1;
        erbe::a=2;
        base::a=3;
    }
};
</code></pre>
<p>also früher dachte ich - man sollte this-&gt;a nehmen - aber mit klassennamen geht es auch direkt. Hm... Der Code ist doch richtig? Zumindest frisst das GCC.</p>
<p>Jetzt meine Frage. So wie es jetzt ist, scheint es mir sauberer zu sein als mit this. Wofür dann this? this wäre universeller - denke ich.</p>
<p>OK - jetzt habe ich ein Problemchen gefunden:</p>
<p>void test(erbe *e)<br />
{<br />
}</p>
<p>mit this könnte ich einen pointer übergeben. mit test(erbe) klappt es hingegen nicht. Wie kann ich es ohne this lösen?</p>
<p><strong>Und die wichtigste Frage. Was kann ich tun um base-pointer an eine funktion zu übergeben - wenn this geht, dann müsste doch was geben um basis-objekt an funktion zu übergeben?</strong></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/152268/this-oder-type</link><generator>RSS for Node</generator><lastBuildDate>Sun, 06 Sep 2026 21:48:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/152268.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 04 Jul 2006 18:37:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to this oder type:: on Tue, 04 Jul 2006 18:38:22 GMT]]></title><description><![CDATA[<p>Oh ich hab jetzt herausgefunden, dass man sowas machen kann:</p>
<pre><code>class base
{
    public:
    int a;
};

class erbe: public base
{
    public:
    int a;

    int foo()
    {
        int a;

        a=1;
        erbe::a=2;
        base::a=3;
    }
};
</code></pre>
<p>also früher dachte ich - man sollte this-&gt;a nehmen - aber mit klassennamen geht es auch direkt. Hm... Der Code ist doch richtig? Zumindest frisst das GCC.</p>
<p>Jetzt meine Frage. So wie es jetzt ist, scheint es mir sauberer zu sein als mit this. Wofür dann this? this wäre universeller - denke ich.</p>
<p>OK - jetzt habe ich ein Problemchen gefunden:</p>
<p>void test(erbe *e)<br />
{<br />
}</p>
<p>mit this könnte ich einen pointer übergeben. mit test(erbe) klappt es hingegen nicht. Wie kann ich es ohne this lösen?</p>
<p><strong>Und die wichtigste Frage. Was kann ich tun um base-pointer an eine funktion zu übergeben - wenn this geht, dann müsste doch was geben um basis-objekt an funktion zu übergeben?</strong></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091400</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091400</guid><dc:creator><![CDATA[TheShadow2000]]></dc:creator><pubDate>Tue, 04 Jul 2006 18:38:22 GMT</pubDate></item><item><title><![CDATA[Reply to this oder type:: on Tue, 04 Jul 2006 19:57:40 GMT]]></title><description><![CDATA[<p>TheShadow2000 schrieb:</p>
<blockquote>
<p>mit this könnte ich einen pointer übergeben. mit test(erbe) klappt es hingegen nicht. Wie kann ich es ohne this lösen?</p>
</blockquote>
<p>Ganz ohne Verwendung von this imho garnicht.</p>
<blockquote>
<p><strong>Und die wichtigste Frage. Was kann ich tun um base-pointer an eine funktion zu übergeben - wenn this geht, dann müsste doch was geben um basis-objekt an funktion zu übergeben?</strong></p>
</blockquote>
<p>Dazu brauchst Du nur zu casten (wobei upcast auch implizit geht)</p>
<pre><code class="language-cpp">void test(base* e);

erbe* e = new erbe;
test(e);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1091418</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091418</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Tue, 04 Jul 2006 19:57:40 GMT</pubDate></item><item><title><![CDATA[Reply to this oder type:: on Tue, 04 Jul 2006 20:10:32 GMT]]></title><description><![CDATA[<p>das hab ich jetzt nicht verstanden...</p>
<p>warum wird da neues Objekt erstellt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091422</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091422</guid><dc:creator><![CDATA[TheShadow2000]]></dc:creator><pubDate>Tue, 04 Jul 2006 20:10:32 GMT</pubDate></item><item><title><![CDATA[Reply to this oder type:: on Wed, 05 Jul 2006 07:10:42 GMT]]></title><description><![CDATA[<p>Weil Du ohne Objekt kein Objekt übergeben kannst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091534</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091534</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Wed, 05 Jul 2006 07:10:42 GMT</pubDate></item><item><title><![CDATA[Reply to this oder type:: on Wed, 05 Jul 2006 07:32:29 GMT]]></title><description><![CDATA[<p>TheShadow2000 schrieb:</p>
<blockquote>
<p>mit this könnte ich einen pointer übergeben. mit test(erbe) klappt es hingegen nicht. Wie kann ich es ohne this lösen?</p>
</blockquote>
<p>Ich verstehs nicht was Du meinst, willst Du einfach einen Zeiger auf Dein Object?</p>
<pre><code class="language-cpp">erbe e;
e.a = 1;
//...
test(*e);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1091548</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091548</guid><dc:creator><![CDATA[THX 1138]]></dc:creator><pubDate>Wed, 05 Jul 2006 07:32:29 GMT</pubDate></item><item><title><![CDATA[Reply to this oder type:: on Wed, 05 Jul 2006 17:50:39 GMT]]></title><description><![CDATA[<p>ach nö... ihr erstellt doch neue Objekte, welche mit basisobjekt nix zu tun haben! Logisch muß ich irgendwas von Objekt übergeben (und nicht etwa die Klasse)</p>
<p>was mir einfällt wäre eine getthis()-methode in basisfunktion, welche ich dann aus neuer klasse auslese und dann weiterreichen kann...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1092061</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1092061</guid><dc:creator><![CDATA[TheShadow2000]]></dc:creator><pubDate>Wed, 05 Jul 2006 17:50:39 GMT</pubDate></item><item><title><![CDATA[Reply to this oder type:: on Wed, 05 Jul 2006 17:54:44 GMT]]></title><description><![CDATA[<p>Hatte nicht gedacht dass es so schwer ist von einem beliebigen erbe* Zeiger auf den konkreten this-Zeiger eines erbe-Objektes (in einer erbe-Methode) zu schliessen...</p>
<pre><code class="language-cpp">void test(base* e);

void erbe::tuwas()
{
  test(this);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1092063</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1092063</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Wed, 05 Jul 2006 17:54:44 GMT</pubDate></item><item><title><![CDATA[Reply to this oder type:: on Wed, 05 Jul 2006 17:54:41 GMT]]></title><description><![CDATA[<p>this is ein ganz normaler rvalue-zeiger der den gewöhnlichen regeln hinsichtlich impliziter (und expliziter) konvertierungen unterliegt.</p>
<pre><code class="language-cpp">class base
{
    public:
    int a;
};
void bar(base*);
class erbe: public base
{
    public:
    int a;

    int foo()
    {
        int a;

        a=1;
        erbe::a=2;
        base::a=3;
        bar(this); // konvertiert this implizit in einen base* pointer der auf das base-subobjekt des aktuellen objekts zeigt
    }
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1092064</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1092064</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Wed, 05 Jul 2006 17:54:41 GMT</pubDate></item></channel></rss>