<?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[Übergabeparameter Operatorüberladung]]></title><description><![CDATA[<p>Folgende Aufgabenstellung:</p>
<p>Durch Operatorüberladung soll ein Konstrukt der Form a/=b möglich werden, wodurch dem Atrribut Ival des Klassenobjekts a das Ergebnis der Integer-Division der Attribute Ival der Klassenobjekte a und b zugewiesen werden soll (also a.Ival=a.Ival/b.Ival)</p>
<p>Folgender Code:</p>
<p>#include &lt;iostream&gt;<br />
using namespace std;</p>
<p>class Exam {</p>
<p>private:<br />
int a,b;<br />
public:<br />
void operator /= (???);<br />
int ival;<br />
};</p>
<p>void Exam::operator /=(???)<br />
{<br />
a.ival /= b.ival;<br />
cout &lt;&lt; a.ival &lt;&lt; endl;</p>
<p>}</p>
<p>int main( void ) {</p>
<p>Exam a,b;<br />
b.ival=2;<br />
a.ival/=b;</p>
<p>a/=b;<br />
return 0;<br />
}</p>
<p>Ich weiß nicht was ich für Übergabeparameter verwenden soll (??)</p>
<p>Vielen Dank für euer Bemühen</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/257197/übergabeparameter-operatorüberladung</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 11:11:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/257197.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 Dec 2009 16:17:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Übergabeparameter Operatorüberladung on Thu, 24 Dec 2009 16:17:07 GMT]]></title><description><![CDATA[<p>Folgende Aufgabenstellung:</p>
<p>Durch Operatorüberladung soll ein Konstrukt der Form a/=b möglich werden, wodurch dem Atrribut Ival des Klassenobjekts a das Ergebnis der Integer-Division der Attribute Ival der Klassenobjekte a und b zugewiesen werden soll (also a.Ival=a.Ival/b.Ival)</p>
<p>Folgender Code:</p>
<p>#include &lt;iostream&gt;<br />
using namespace std;</p>
<p>class Exam {</p>
<p>private:<br />
int a,b;<br />
public:<br />
void operator /= (???);<br />
int ival;<br />
};</p>
<p>void Exam::operator /=(???)<br />
{<br />
a.ival /= b.ival;<br />
cout &lt;&lt; a.ival &lt;&lt; endl;</p>
<p>}</p>
<p>int main( void ) {</p>
<p>Exam a,b;<br />
b.ival=2;<br />
a.ival/=b;</p>
<p>a/=b;<br />
return 0;<br />
}</p>
<p>Ich weiß nicht was ich für Übergabeparameter verwenden soll (??)</p>
<p>Vielen Dank für euer Bemühen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1827385</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1827385</guid><dc:creator><![CDATA[matzehilto]]></dc:creator><pubDate>Thu, 24 Dec 2009 16:17:07 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabeparameter Operatorüberladung on Thu, 24 Dec 2009 16:19:25 GMT]]></title><description><![CDATA[<p>statt a.ival/=b; wollt ich natürlich schreiben a.ival=2;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1827386</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1827386</guid><dc:creator><![CDATA[matzehilto]]></dc:creator><pubDate>Thu, 24 Dec 2009 16:19:25 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabeparameter Operatorüberladung on Thu, 24 Dec 2009 16:51:37 GMT]]></title><description><![CDATA[<p><a href="http://magazin.c-plusplus.net/artikel/%DCberladung%20von%20Operatoren%20in%20CPlusPlus%20%28Teil%201%29" rel="nofollow">http://magazin.c-plusplus.net/artikel/�berladung von Operatoren in CPlusPlus (Teil 1)</a></p>
<p>Grüße und frohe Weihnachten ... Heiko</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1827396</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1827396</guid><dc:creator><![CDATA[bwbg]]></dc:creator><pubDate>Thu, 24 Dec 2009 16:51:37 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabeparameter Operatorüberladung on Thu, 24 Dec 2009 17:13:02 GMT]]></title><description><![CDATA[<p>Danke für die Antwort und dir auch ein frohes und gesegnetes Fest.</p>
<p>Ich hab aber immer noch ein Problem:</p>
<p>wenn ich schreib<br />
void Exam::operator/=(Exam &amp;x)<br />
und möchte dort die Rechenoperation ausführen dann brauch ich auch den Wert a.ival oder?</p>
<p>a/=b; bedeutet das a.operator/=b; wobei operator/= gleich der Funktionsnahme ist und b quasi der übergebene Parameter oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1827400</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1827400</guid><dc:creator><![CDATA[matzehilto]]></dc:creator><pubDate>Thu, 24 Dec 2009 17:13:02 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabeparameter Operatorüberladung on Thu, 24 Dec 2009 17:28:58 GMT]]></title><description><![CDATA[<p>Naja ich muss dann jetzt mal los.<br />
Danke für die Hilfe und nochmals allen Frohe Weihnachten!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1827405</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1827405</guid><dc:creator><![CDATA[matzehilto]]></dc:creator><pubDate>Thu, 24 Dec 2009 17:28:58 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabeparameter Operatorüberladung on Fri, 25 Dec 2009 13:11:33 GMT]]></title><description><![CDATA[<p>Ich hab jetzt meinen Fehler selber gefunden.<br />
Geduld zahlt sich eben aus.<br />
Falls jemand interessiert hier der Code:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

class Exam {

public:
  void operator /= (Exam &amp;x);
  int ival; 
};

void Exam::operator /= (Exam &amp;b)
{
	cout &lt;&lt; b.ival &lt;&lt; endl;
	ival = b.ival / ival;
};

int main( void ) {

  Exam a,b;
  a.ival=5;
  b.ival=10;

a/= b;
// Man kann auch a.operator+=(b); schreiben
//Wichtig!!: dank dem this-Zeiger wird die Adresse 
// des aktuellen Objekts übergeben
// des heißt der Wert von Ival der dem a zugeordnet wurde
// mann kann auch this-&gt;ival schreiben muss man aber nicht
cout &lt;&lt; a.ival &lt;&lt; endl;

   return 0;
}
</code></pre>
<p>/edit pumu: cpp-Tags. Nächstemal bitte selber machen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1827639</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1827639</guid><dc:creator><![CDATA[matzehilto]]></dc:creator><pubDate>Fri, 25 Dec 2009 13:11:33 GMT</pubDate></item></channel></rss>