<?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[+ Operator für eigenen Datentyp]]></title><description><![CDATA[<p>Hallo Leute!</p>
<p>Ich habe einen langen ganzzahligen Integer als Klasse programmiert. Leider weiß ich nicht genau wie ich es mache, dass z.B. der &quot;=&quot; Operator funktioniert.</p>
<pre><code class="language-cpp">class LONGINT {
public:
	bool bit[512];
	LONGINT();
	LONGINT(double zahl);
	LONGINT LONGINT::operator=(LONGINT zahl);
	double toDouble();

};
</code></pre>
<pre><code class="language-cpp">LONGINT LONGINT::operator=(LONGINT zahl) {
	LONGINT kopie();
	for(i=0;i&lt;sizeof(LONGINT) {
		kopie.bit[i]=zahl.bit[i];
	}
	return kopie;
}
</code></pre>
<p>Kann mir da jemand auf die Sprünge helfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/230145/operator-für-eigenen-datentyp</link><generator>RSS for Node</generator><lastBuildDate>Sun, 27 Sep 2026 12:15:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/230145.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 21 Dec 2008 15:34:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 15:34:26 GMT]]></title><description><![CDATA[<p>Hallo Leute!</p>
<p>Ich habe einen langen ganzzahligen Integer als Klasse programmiert. Leider weiß ich nicht genau wie ich es mache, dass z.B. der &quot;=&quot; Operator funktioniert.</p>
<pre><code class="language-cpp">class LONGINT {
public:
	bool bit[512];
	LONGINT();
	LONGINT(double zahl);
	LONGINT LONGINT::operator=(LONGINT zahl);
	double toDouble();

};
</code></pre>
<pre><code class="language-cpp">LONGINT LONGINT::operator=(LONGINT zahl) {
	LONGINT kopie();
	for(i=0;i&lt;sizeof(LONGINT) {
		kopie.bit[i]=zahl.bit[i];
	}
	return kopie;
}
</code></pre>
<p>Kann mir da jemand auf die Sprünge helfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633627</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633627</guid><dc:creator><![CDATA[dahaack]]></dc:creator><pubDate>Sun, 21 Dec 2008 15:34:26 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 15:45:44 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">class LONGINT { //warum caps? sieht aus wie makro aber nicht wie klasse...
public:
    bool bit[512];
    LONGINT();
    LONGINT(double zahl);
    LONGINT&amp; operator=(const LONGINT &amp;zahl); //so geht das...
    double toDouble();
};
</code></pre>
<pre><code class="language-cpp">LONGINT&amp; LONGINT::operator=(const LONGINT &amp;zahl) {
    //das ist falsch: LONGINT kopie();
    for(i=0; i&lt;sizeof(LONGINT) { //find ich auch nicht gerade elegant - vll solltest du eher nen static const size_t in deiner klasse für die länge speichern ^^
        bit[i]=zahl.bit[i]; //entspricht ja this-&gt;bit[i] = zahl.bit[i];
    }
    return *this; //der rückgabewert ist der gerade zugewiesene wert - also das gerade bearbeitete objekt (ein dereferenziertes this)
}
</code></pre>
<p>besser?<br />
bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633633</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633633</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sun, 21 Dec 2008 15:45:44 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 16:11:02 GMT]]></title><description><![CDATA[<p>Hallo unskilled!</p>
<p>Erstmal vielen Dank für deine Antwort.</p>
<p>Leider will er trotzdem noch nicht.</p>
<pre><code class="language-cpp">class LONGINT {
public:
	bool bit[512];
	LONGINT();
	LONGINT(double zahl);
	LONGINT&amp; operator=(const LONGINT &amp;zahl);
	double toDouble();

};

LONGINT&amp; LONGINT::operator=(const LONGINT &amp;zahl) {
	int i;
	for(i=0;i&lt;sizeof(LONGINT);i++) {
		bit[i]=zahl.bit[i];
	}
	return *this;
}

void main() {
	LONGINT zahl1(1e100);
	LONGINT zahl2();
	zahl2=zahl1;  //error C2659: '=' : overloaded function as left operand
	printf(&quot;%g\n\n&quot;, zahl2.toDouble());   //error C2228: left of '.toDouble' must have class/struct/union type
}
</code></pre>
<p>Es gibt keinen Fehler, wenn...</p>
<pre><code class="language-cpp">void main() {
    LONGINT zahl1(1e100);
    LONGINT zahl2();
    //zahl2=zahl1;
    printf(&quot;%g\n\n&quot;, zahl1.toDouble());
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1633649</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633649</guid><dc:creator><![CDATA[dahaack]]></dc:creator><pubDate>Sun, 21 Dec 2008 16:11:02 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 16:17:46 GMT]]></title><description><![CDATA[<p>Oh ich bin ein Trottel.</p>
<p>Es geht doch! LONGINT zahl2(); hat nicht funktioniert. Vielen Dank nochmal!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633653</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633653</guid><dc:creator><![CDATA[dahaack]]></dc:creator><pubDate>Sun, 21 Dec 2008 16:17:46 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 16:19:24 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">LONGINT zahl2();
</code></pre>
<p>Das ist eine Funktionsdeklaration. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1633654</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633654</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 21 Dec 2008 16:19:24 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 16:21:20 GMT]]></title><description><![CDATA[<p>Ja, und die Definition sieht so aus:</p>
<pre><code class="language-cpp">LONGINT::LONGINT() {
	int i;
	for(i=0;i&lt;sizeof(bit);i++) {
		bit[i]=0;
	}
}
</code></pre>
<p>Warum geht das nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633655</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633655</guid><dc:creator><![CDATA[dahaack]]></dc:creator><pubDate>Sun, 21 Dec 2008 16:21:20 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 16:25:31 GMT]]></title><description><![CDATA[<p>Das sieht wie die Implementierung eines Konstruktor aus. Was geht an dem nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633658</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 21 Dec 2008 16:25:31 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 16:42:56 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>Das sieht wie die Implementierung eines Konstruktor aus. Was geht an dem nicht?</p>
</blockquote>
<p>Richtig.</p>
<pre><code class="language-cpp">void main() {
	LONGINT zahl();
	printf(&quot;%g\n\n&quot;, zahl.toDouble()); //error C2228: left of '.toDouble' must have class/struct/union type
}
</code></pre>
<p>Wenn ich das printf rausnehme und den Debugger nach LONGINT zahl(); anhalte kennt er die Varianle zahl garnicht.</p>
<p>ERROR: Symbol &quot;zahl&quot; not found</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633665</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633665</guid><dc:creator><![CDATA[dahaack]]></dc:creator><pubDate>Sun, 21 Dec 2008 16:42:56 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 16:44:04 GMT]]></title><description><![CDATA[<p>Er sprintg auch garnicht in den Konstruktor rein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633666</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633666</guid><dc:creator><![CDATA[dahaack]]></dc:creator><pubDate>Sun, 21 Dec 2008 16:44:04 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 16:57:07 GMT]]></title><description><![CDATA[<p>Wie schon gesagt, beschreibt das hier:</p>
<pre><code class="language-cpp">LONGINT zahl();
</code></pre>
<p>Eine Funktionsdeklaration.</p>
<p>Wenn du ein Objekt instanzieren willst, dann ohne die Klammern:</p>
<pre><code class="language-cpp">LONGINT zahl;
</code></pre>
<p>Ausser du willst natürlich einen nicht-Defaultkonstruktor aufrufen, dann kannst du natürlich noch die Argumente in den Klammern angeben.</p>
<pre><code class="language-cpp">LONGINT zahl ( 2.0 ); //z.B
</code></pre>
<p>Dann wird aber auch nicht der Default-Konstruktor aufgerufen, sondern einer der überladenen. (Dementsprechend auf eine anderen Implementierung davon).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633670</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633670</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 21 Dec 2008 16:57:07 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 17:14:54 GMT]]></title><description><![CDATA[<p>Okay es funktioniert ohne Klammern.</p>
<p>Ich versteh nur nicht ganz warum es jetzt beim überladenen geht und beim Defaultkonstruktor nicht. Ist das immer so?</p>
<p>Bei beiden werden den Bits[0....x] 1en oder 0en zugewiesen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633677</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633677</guid><dc:creator><![CDATA[dahaack]]></dc:creator><pubDate>Sun, 21 Dec 2008 17:14:54 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 17:19:38 GMT]]></title><description><![CDATA[<p>dahaack schrieb:</p>
<blockquote>
<p>Okay es funktioniert ohne Klammern.</p>
<p>Ich versteh nur nicht ganz warum es jetzt beim überladenen geht und beim Defaultkonstruktor nicht. Ist das immer so?</p>
<p>Bei beiden werden den Bits[0....x] 1en oder 0en zugewiesen.</p>
</blockquote>
<p>Jopp, ist es...<br />
Weil der COmpiler denkt, dass das eine eine Funktionsdeklaration ist...</p>
<pre><code class="language-cpp">LONGINT zahl();
// ^-- Rückgabe-Typ
//       ^----Name
//           ^---Parameterliste (in dem Fal dann void)
</code></pre>
<p>Wenn du mal überlegst sieht eine Funktionsdeklaration ja wirklich genau so aus:</p>
<pre><code class="language-cpp">int getMyIQ()
{
 return std::numeric_limits&lt;int&gt;::max(); //^^
}
</code></pre>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633682</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633682</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sun, 21 Dec 2008 17:19:38 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 17:50:25 GMT]]></title><description><![CDATA[<p>Okay <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>Vielen Dank euch beiden!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633696</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633696</guid><dc:creator><![CDATA[dahaack]]></dc:creator><pubDate>Sun, 21 Dec 2008 17:50:25 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 18:37:08 GMT]]></title><description><![CDATA[<p>Wie mach ich das denn jetzt mit einem + Operator? Da will ich den linken Summanden ja nicht überschreiben, sondern nur das Zwischenergebnis nach links reichen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633716</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633716</guid><dc:creator><![CDATA[dahaack]]></dc:creator><pubDate>Sun, 21 Dec 2008 18:37:08 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 19:00:30 GMT]]></title><description><![CDATA[<p>dahaack schrieb:</p>
<blockquote>
<p>Wie mach ich das denn jetzt mit einem + Operator? Da will ich den linken Summanden ja nicht überschreiben, sondern nur das Zwischenergebnis nach links reichen.</p>
</blockquote>
<pre><code class="language-cpp">LONGINT operator + ( const LONGINT &amp; lhs , const LONGINT &amp; rhs )
{
 LONGINT temp ( lhs );
 return temp += rhs;
}
</code></pre>
<p>Oder natürlich auch gleich die einzelnen Werten nehmen, addieren und dann ein neues Objekt erzeugen.</p>
<p>EDIT:<br />
Natürlich musst du dazu auch zuerst den += - Operator definieren. Der ist aber prinzipiell dem = - Operator sehr ähnlich.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633732</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633732</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 21 Dec 2008 19:00:30 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 21:39:44 GMT]]></title><description><![CDATA[<p>Leider bekomm ichs noch nicht hin. Der += Operator funzt. Beim + werden 2 Fehlermeldungen ausgegeben:</p>
<pre><code class="language-cpp">class LONGINT {
public:
	bool bit[48];
	LONGINT();
	LONGINT(double zahl);
	LONGINT&amp; operator=(const LONGINT &amp;zahl);
	LONGINT&amp; operator+=(const LONGINT &amp;zahl);
	LONGINT&amp; operator+(const LONGINT &amp; lhs, const LONGINT &amp; rhs ); //error C2804: binary 'operator +' has too many parameters
	double toDouble();

};
</code></pre>
<pre><code class="language-cpp">void main() {
	LONGINT zahl1=120;
	LONGINT zahl2=-10;
	LONGINT zahl3(10);
	zahl3=zahl1+zahl2; //error C2676: binary '+' : 'class LONGINT' does not define this operator or a conversion to a type acceptable to the predefined operator
	printf(&quot;%g\n\n&quot;, zahl3.toDouble());
	printf(&quot;%i\n\n&quot;, (int)(1&amp;1));
}
</code></pre>
<pre><code class="language-cpp">LONGINT operator + ( const LONGINT &amp; lhs , const LONGINT &amp; rhs )
{
 LONGINT temp ( lhs );
 return temp += rhs;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1633812</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633812</guid><dc:creator><![CDATA[dahaack]]></dc:creator><pubDate>Sun, 21 Dec 2008 21:39:44 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 21:48:21 GMT]]></title><description><![CDATA[<p>Der Operator + sollte auch keine Memberfunktion sein. Verändert ja an keinem der beiden Objekte etwas. Also nimm sie einfach raus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633816</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633816</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 21 Dec 2008 21:48:21 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 22:15:52 GMT]]></title><description><![CDATA[<p>Die Memberfunktion ist die</p>
<pre><code>LONGINT&amp; operator+(const LONGINT &amp; lhs, const LONGINT &amp; rhs );
</code></pre>
<p>?</p>
<p>Wenn ich die Zeile rausnehme sagt er bei</p>
<pre><code>zahl3=zahl1+zahl2;
</code></pre>
<p>error C2676: binary '+' : 'class LONGINT' does not define this operator or a conversion to a type acceptable to the predefined operator</p>
<p>Ich checks nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633825</guid><dc:creator><![CDATA[dahaack]]></dc:creator><pubDate>Sun, 21 Dec 2008 22:15:52 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 22:26:50 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">class LONGINT {
   // ...

   friend LONGINT operator+( const LONGINT&amp;, const LONGINT&amp; );
};

LONGINT operator+( const LONGINT&amp; lhs, const LONGINT&amp; rhs )
{
   // Implementation
}
</code></pre>
<p>oder alternativ (z.B. für Einzeiler)</p>
<pre><code class="language-cpp">class LONGINT {
   // ...

   friend LONGINT operator+( const LONGINT&amp; lhs, const LONGINT&amp; rhs ) { /* Implementation */ }
};
</code></pre>
<p>Was wichtig ist, ist zu bemerken, dass in beiden Fällen der operator+ KEINE Memberfunktion ist (der aufruf foobar.operator+( foo1, foo2 ) ist ungültig, da es eine Memberfunktion operator+ nicht gibt).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633828</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633828</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 21 Dec 2008 22:26:50 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 22:35:26 GMT]]></title><description><![CDATA[<p>Jo, es funktioniert, Danke!</p>
<p>Aber was ist denn jetzt eine Memberfunktion? Bei wiki steht:</p>
<p>Memberfunktionen (auch Elementfunktionen oder Methoden genannt) sind innerhalb einer Klasse deklarierte Funktionen. In einem konsequent objektorientiert geschriebenen Programm sollte jede Funktion außer der Funktion main() Memberfunktion einer Klasse sein.</p>
<p>Dadurch bin ich ja jetzt auch nicht viel schlauer geworden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633836</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633836</guid><dc:creator><![CDATA[dahaack]]></dc:creator><pubDate>Sun, 21 Dec 2008 22:35:26 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 22:43:15 GMT]]></title><description><![CDATA[<p>friend-Funktionen können keine Member-Funktionen der Klasse selber sein (und es würde freilich auch wenig sinn machen, weil Memberfunktionen ja sowieso Zugriff auf private-Member der Klasse haben).<br />
Im ersten Fall sagst du innerhalb der Klassendefinition nur, dass es eine &quot;globale&quot; Funktion operator+(...) gibt, die Zugriff auf alle Member der Klasse hat. Im zweiten gibst du auch gleich noch den Funktionsrumpf für diese Funktion mit.<br />
In Worten des Standards kann ich das aber leider im Moment nicht ausdrücken. Da muss mir hier mal einer der Gurus aushelfen <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>Viele Grüße,<br />
Michael</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633838</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633838</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 21 Dec 2008 22:43:15 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 22:43:28 GMT]]></title><description><![CDATA[<p>In C++ ist es eine Memberfunktion, wenn implizit der this Zeiger mitgegeben wird. Also alle Funktionen, die du innerhalb einer Klasse deklarierst, ausser statische und friend-Funktionen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633839</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633839</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 21 Dec 2008 22:43:28 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 22:59:26 GMT]]></title><description><![CDATA[<p>Naja, eine friend-Funktion kann ja durchaus eine Memberfunktion sein, nur nicht in der Klasse, in der sie als friend deklariert wird.</p>
<pre><code class="language-cpp">void globalFunc(); // keine Memberfunktion

class a {
   void func1();             // Memberfunktion von a
   friend void globalFunc(); // Keine Memberfunktion
   static void func2();      // Statische Memberfunktion
};

class b {
   void func1();             // Memberfunktion von b
   friend void a::funct1();  // Keine Memberfunktion von b (aber von a!)
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1633842</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633842</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 21 Dec 2008 22:59:26 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 22:58:42 GMT]]></title><description><![CDATA[<p>Berichtigung:<br />
Funktionen, die in einer Klasse definiert sind, ausser denen, die mit friend deklariert sind, sind Memberfunktionen. Wenn sie mit static deklariert ist, ist es eine statische Memberfunktion, ansonsten eine nicht-statische Memberfunktion <strong>dieser</strong> Klasse.<br />
Eine statische Funktion hat keinen this-Pointer. (eine friend-Funktion oder Klasse ebensowenig).</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/34233">@Decimad</a>:</p>
<pre><code class="language-cpp">static void func2();      // Keine Memberfunktion
</code></pre>
<p>Laut Standard ist das eben eine Memberfunktion, aber halt eine statische. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1633849</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633849</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 21 Dec 2008 22:58:42 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Sun, 21 Dec 2008 22:59:51 GMT]]></title><description><![CDATA[<p>Wenn das mal nicht kompliziert ist <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>PS: Korrigiert, danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633850</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633850</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 21 Dec 2008 22:59:51 GMT</pubDate></item><item><title><![CDATA[Reply to + Operator für eigenen Datentyp on Mon, 22 Dec 2008 08:27:44 GMT]]></title><description><![CDATA[<p>dahaack: es wäre vielleicht sinnvoll, wenn du dir ein paar Grundlagen zur Operatorüberladung anschaust. Wichtige Punkte sind dabei:<br />
- Welche Operatoren sollte man als Klassenmember implementieren, welche als freie Funktionen?<br />
- Wie sieht die typische Funktionssignatur der Operatoren aus (Argumente, Rückgabetyp, const oder nicht, Referenz oder nicht usw.)<br />
- Wie sehen typische Implementierungen aus (z.B. copy&amp;swap für op=, op+ mittels op+= implementieren usw.)</p>
<p>dazu noch einen kleinen Tip, der früher oder später in der einen oder anderen Form sowieso gekommen wäre:<br />
Sätze wie &quot;Ich krieg eine Fehlermeldung&quot; oder &quot;Das funktioniert nicht&quot; werden hier im Forum gerne mal mit Hinweisen auf defekte Glaskugeln gahndet. Wenn du nicht dazuschreibst wie die Fehlermeldung lautet oder wie sich das &quot;nicht funktionieren&quot; äußert (Absturz, Kompilierungsfehler, unerwartetes Verhalten,...) kann man meist nur raten oder sich deinen Code durchlesen. Wenn du Fehlermeldungen angibst weiß meist jemand ziemlich genau wonach man suchen muss, und der Fehler ist schnell gefunden <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1633917</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633917</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 22 Dec 2008 08:27:44 GMT</pubDate></item></channel></rss>