<?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[&amp;amp;#927;bjektorientierung]]></title><description><![CDATA[<p>Eine frage:<br />
wenn ich beispielsweise 1 Objekt der klasse CKLASSE die als variable eine Zahl speichert und eine Methode besitzt um diese zu ändern besitze und außerdem 2 Objekte a und b von der Klasse ab erstelle die als variable das Objekt c besitzen. Wenn ich dann in a die Zahl in c aendere, dann ändert sich doch nicht c in b oder?<br />
Was muss ich machen damit das passiert? Danke für eine Antwort<br />
Niko</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/257082/amp-927-bjektorientierung</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 14:51:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/257082.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 22 Dec 2009 13:54:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to &amp;amp;#927;bjektorientierung on Tue, 22 Dec 2009 13:54:16 GMT]]></title><description><![CDATA[<p>Eine frage:<br />
wenn ich beispielsweise 1 Objekt der klasse CKLASSE die als variable eine Zahl speichert und eine Methode besitzt um diese zu ändern besitze und außerdem 2 Objekte a und b von der Klasse ab erstelle die als variable das Objekt c besitzen. Wenn ich dann in a die Zahl in c aendere, dann ändert sich doch nicht c in b oder?<br />
Was muss ich machen damit das passiert? Danke für eine Antwort<br />
Niko</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1826391</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1826391</guid><dc:creator><![CDATA[greece57]]></dc:creator><pubDate>Tue, 22 Dec 2009 13:54:16 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;amp;#927;bjektorientierung on Tue, 22 Dec 2009 14:01:34 GMT]]></title><description><![CDATA[<p>Wenn ich dich richtig verstanden habe, suchst du sowas wie geteilte Besitzverhältnisse. Dafür wäre deine Beschreibung aber verdammt kompliziert.</p>
<p>Ansonsten: Kannst du das nochmals deutlicher formulieren? Was ist die Klasse <code>ab</code> ? Was ist <code>c</code> ? Am besten illustrierst du dein Anliegen an einem kleinen Stück Code.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1826394</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1826394</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Tue, 22 Dec 2009 14:01:34 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;amp;#927;bjektorientierung on Tue, 22 Dec 2009 16:26:11 GMT]]></title><description><![CDATA[<p>Hatte es leider eilig, tut mir leid:</p>
<p>Also es gibt eine Klasse KLASSEC und eine Klasse KLASSEAB:</p>
<pre><code class="language-cpp">class KLASSEC
{
      private:

          int zahl;

      public:

           KLASSEC();
           void setZahl(int z);
           int getZahl();

};

void KLASSEC::setZahl(int z)
{
      zahl = z;
}

int KLASSEC::getZahl()
{
      return zahl;
}

KLASSEC::KLASSEC()
{
      zahl = 0;
}
</code></pre>
<pre><code class="language-cpp">class KLASSEAB
{
      private:

          KLASSEC Objekt;

      public:

           KLASSEAB(KLASSEC nObjekt);
           void setZahl(int z);
           void getZahl();

};

void KLASSEAB::setZahl(int z)
{
      Objekt.setZahl(z);
}

void KLASSEAB::getZahl()
{
      cout &lt;&lt; Objekt.getZahl(z);
}

KLASSEC::KLASSEC()
{
      Objekt = nObjekt;
}
</code></pre>
<p>so in main erzeug ich 1 Objekt vom Typ KLASSEC und 2 Objekte vom Typ KLASSEAB die als Objekt das vorhin erzeugt objekt bekommen:</p>
<pre><code class="language-cpp">int main(void)
{
       KLASSEC c;
       KLASSEAB a (c); //wie übergibt man noch mal Objekte an den konstruktor??
       KLASSEAB b (c);

       a.setZahl(2);
       b.getZahl();

       return 0;
}
</code></pre>
<p>So was kommt jetzt raus?<br />
0 oder?<br />
wie krieg ich da 2 raus?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1826470</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1826470</guid><dc:creator><![CDATA[greece5(7)]]></dc:creator><pubDate>Tue, 22 Dec 2009 16:26:11 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;amp;#927;bjektorientierung on Tue, 22 Dec 2009 16:35:57 GMT]]></title><description><![CDATA[<p>Das bekommst du mit Hilfe von Referenzen.</p>
<p>Hier deine Klasse so modifiziert das sie eine Referenz verwendet:</p>
<pre><code class="language-cpp">class KLASSEAB
{
      private:

          KLASSEC &amp; Objekt;

      public:

           KLASSEAB(KLASSEC &amp; nObjekt);
           void setZahl(int z);
           void getZahl();

};

void KLASSEAB::setZahl(int z)
{
      Objekt.setZahl(z);
}

void KLASSEAB::getZahl()
{
      cout &lt;&lt; Objekt.getZahl(z);
}

KLASSEAB::KLASSEAB( KLASSEC &amp; nObject )
: Objekt( nObjekt )
{
}
</code></pre>
<p>BR</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1826476</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1826476</guid><dc:creator><![CDATA[evilissimo]]></dc:creator><pubDate>Tue, 22 Dec 2009 16:35:57 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;amp;#927;bjektorientierung on Wed, 23 Dec 2009 19:51:58 GMT]]></title><description><![CDATA[<p>Hatte ich fast vergessen:<br />
Danke vielmals - und ein frohes Fest</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1826988</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1826988</guid><dc:creator><![CDATA[greece57]]></dc:creator><pubDate>Wed, 23 Dec 2009 19:51:58 GMT</pubDate></item></channel></rss>