<?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[Klasse - Methodendeklaration]]></title><description><![CDATA[<p>Hi,</p>
<p>Welches der beiden Deklarationen ist mehr C++ Standard bzw. besser:</p>
<p>1:<br />
class Mensch<br />
{<br />
char vorname[20];<br />
char name[20];<br />
unsigned int alter;<br />
char geschlecht;</p>
<p>void set_vorname(const char *);<br />
void set_name(const char *);<br />
void set_alter(unsigned int);<br />
void set_geschlecht(char);<br />
};</p>
<p>oder<br />
2:<br />
class Mensch<br />
{<br />
char vorname[20];<br />
char name[20];<br />
unsigned int alter;<br />
char geschlecht;</p>
<p>void set_vorname(const char *vorname);<br />
void set_name(const char *name);<br />
void set_alter(unsigned int alter);<br />
void set_geschlecht(char geschlecht);<br />
};</p>
<p>lg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/288930/klasse-methodendeklaration</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 08:53:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/288930.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 Jun 2011 14:35:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Sat, 25 Jun 2011 14:35:24 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>Welches der beiden Deklarationen ist mehr C++ Standard bzw. besser:</p>
<p>1:<br />
class Mensch<br />
{<br />
char vorname[20];<br />
char name[20];<br />
unsigned int alter;<br />
char geschlecht;</p>
<p>void set_vorname(const char *);<br />
void set_name(const char *);<br />
void set_alter(unsigned int);<br />
void set_geschlecht(char);<br />
};</p>
<p>oder<br />
2:<br />
class Mensch<br />
{<br />
char vorname[20];<br />
char name[20];<br />
unsigned int alter;<br />
char geschlecht;</p>
<p>void set_vorname(const char *vorname);<br />
void set_name(const char *name);<br />
void set_alter(unsigned int alter);<br />
void set_geschlecht(char geschlecht);<br />
};</p>
<p>lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2083856</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2083856</guid><dc:creator><![CDATA[Jeffson]]></dc:creator><pubDate>Sat, 25 Jun 2011 14:35:24 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Sun, 26 Jun 2011 08:25:42 GMT]]></title><description><![CDATA[<p>Erstens: Aus Sicht des Compilers sind beide gleich gut. Aus Sicht eines Verwenders der Klasse würde ich die <s>erste</s> zweite bevorzugen.</p>
<p>Zweitens: Gute C++ Programmierer verwenden keine nackten char-Arrays und -Zeiger, sondern std::string. Und private Setter sind imho unnötig.</p>
<p>Drittens: sfds</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2083859</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2083859</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sun, 26 Jun 2011 08:25:42 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Sat, 25 Jun 2011 15:00:43 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>...Und private Setter sind imho unnötigSyntaxcoloring:</p>
</blockquote>
<p>Ok, private Methoden bringen mir in diesem Fall tatsächlich nichts. Aber wenn ich die Methoden public mache, dann ist es doch gut oder? Besser, als auf die Eigenschaften direkt (public) zuzugreifen.<br />
--&gt; <strong>Zweite Frage:<br />
Wenn ich die Methoden nicht explizit public mache, dann kann ich doch nicht auf die Methoden von außen zugreifen oder? Da sie dann private sind.</strong></p>
<p>lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2083870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2083870</guid><dc:creator><![CDATA[Jeffson]]></dc:creator><pubDate>Sat, 25 Jun 2011 15:00:43 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Sat, 25 Jun 2011 15:09:07 GMT]]></title><description><![CDATA[<p>Jeffson schrieb:</p>
<blockquote>
<p>Besser, als auf die Eigenschaften direkt (public) zuzugreifen.</p>
</blockquote>
<p>Sehr schöne Frage <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Jeffson schrieb:</p>
<blockquote>
<p>Wenn ich die Methoden nicht explizit public mache, dann kann ich doch nicht auf die Methoden von außen zugreifen oder?</p>
</blockquote>
<p>Jop.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2083880</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2083880</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Sat, 25 Jun 2011 15:09:07 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Sat, 25 Jun 2011 15:09:46 GMT]]></title><description><![CDATA[<p>Ja, wenn du die Methoden public setzt, bringen sie etwas. Allerdings wirst du beim Thema Getter/Setter hier auf geteiltes Echo stoßen (nur mal als Vorwarnung).</p>
<p>Jeffson schrieb:</p>
<blockquote>
<p>--&gt; <strong>Zweite Frage:<br />
Wenn ich die Methoden nicht explizit public mache, dann kann ich doch nicht auf die Methoden von außen zugreifen oder? Da sie dann private sind.</strong></p>
<p>lg</p>
</blockquote>
<p>Ja, solange du in der class keine anderen Sichtbarkeitsmodifikationen angegeben hast, sind die Member privat und damit von außen nicht verwendbar (abgesehen von friends und einigen illegalen Präprozessor-Tricks).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2083881</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2083881</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sat, 25 Jun 2011 15:09:46 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Sat, 25 Jun 2011 15:23:13 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>Ja, wenn du die Methoden public setzt, bringen sie etwas. Allerdings wirst du beim Thema Getter/Setter hier auf geteiltes Echo stoßen ...</p>
</blockquote>
<p>Hast du einen besseren Vorschlag? Her damit</p>
<p>lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2083892</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2083892</guid><dc:creator><![CDATA[Jeffson]]></dc:creator><pubDate>Sat, 25 Jun 2011 15:23:13 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Sat, 25 Jun 2011 15:28:55 GMT]]></title><description><![CDATA[<p>Jeffson schrieb:</p>
<blockquote>
<p>Ok, private Methoden bringen mir in diesem Fall tatsächlich nichts. Aber wenn ich die Methoden public mache, dann ist es doch gut oder? Besser, als auf die Eigenschaften direkt (public) zuzugreifen.</p>
</blockquote>
<p>Das kommt ganz da drauf an, was die Methoden machen.</p>
<blockquote>
<p>--&gt; <strong>Zweite Frage:<br />
Wenn ich die Methoden nicht explizit public mache, dann kann ich doch nicht auf die Methoden von außen zugreifen oder? Da sie dann private sind.</strong></p>
</blockquote>
<p>Ja, bei class ist die Defaultsichtbarkeit (d.h. wenn man nichts angibt) private, bei structs ist sie public. Das ist übrigens der einzige (technische) Unterschied zwischen class und struct.</p>
<p>edit: Oje, da war ich viel zu langsam. Sollte mal die Threadansicht aktualisieren, bevor ich antworte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2083896</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2083896</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sat, 25 Jun 2011 15:28:55 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Sun, 26 Jun 2011 07:50:11 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Ja, bei class ist die Defaultsichtbarkeit (d.h. wenn man nichts angibt) private, bei structs ist sie public. Das ist übrigens der einzige (technische) Unterschied zwischen class und struct.</p>
</blockquote>
<p>Deswegen passt class auch viel besser ins OOP-Schema.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2084166</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2084166</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 26 Jun 2011 07:50:11 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Sun, 26 Jun 2011 08:17:25 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>Aus Sicht eines Verwenders der Klasse würde ich die erste bevorzugen.</p>
</blockquote>
<p>Echt? Parameterlisten ohne Parameternamen?<br />
Sag das nochmal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2084174</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2084174</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sun, 26 Jun 2011 08:17:25 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Sun, 26 Jun 2011 08:23:58 GMT]]></title><description><![CDATA[<p>Jeffson schrieb:</p>
<blockquote>
<p>Hast du einen besseren Vorschlag? Her damit</p>
</blockquote>
<p>Statt</p>
<pre><code class="language-cpp">char vorname[20];
void set_vorname(const char *vorname)
{
   if(strlen(this-&gt;vorname)&gt;=20)
      throw std::wtf_exception(&quot;name too long&quot;);
   strcpy(vorname,this-&gt;vorname);
}
</code></pre>
<p>kann man auch</p>
<pre><code class="language-cpp">std::string vorname;
</code></pre>
<p>machen.</p>
<p>Was noch die Frage sein wird, ist, ob man einen öffentlichen setter haben mag(, um ungültige Namen herauszufiltern,) oder lieber keinen haben will und stattdessen nur einen Namensprüfer und im Kostruktor den Namen verlangt und damit echten Schreibschutz durchsetzt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2084175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2084175</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sun, 26 Jun 2011 08:23:58 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Sun, 26 Jun 2011 08:25:00 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>CStoll schrieb:</p>
<blockquote>
<p>Aus Sicht eines Verwenders der Klasse würde ich die erste bevorzugen.</p>
</blockquote>
<p>Echt? Parameterlisten ohne Parameternamen?<br />
Sag das nochmal.</p>
</blockquote>
<p>Klar doch - das bietet mir mehr Raum ür Interpretationen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Nein ernsthaft: Du hast mich erwischt, ich meinte natürlich die andere Variante.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2084176</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2084176</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sun, 26 Jun 2011 08:25:00 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Mon, 27 Jun 2011 22:01:06 GMT]]></title><description><![CDATA[<p>C++ kennt keine Methoden, nur Memberfunktionen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2085144</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085144</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Mon, 27 Jun 2011 22:01:06 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Mon, 27 Jun 2011 22:22:53 GMT]]></title><description><![CDATA[<p>314159265358979 schrieb:</p>
<blockquote>
<p>C++ kennt keine Methoden, nur Memberfunktionen!</p>
</blockquote>
<p>Doch, das sind auch Methoden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2085155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085155</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 27 Jun 2011 22:22:53 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Mon, 27 Jun 2011 22:29:59 GMT]]></title><description><![CDATA[<p>Falsch. Memberfunktionen sind Funktionen, bei denen this als erster Parameter implizit übergeben wird. Methoden können auch x-beliebige andere Objekte sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2085159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085159</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Mon, 27 Jun 2011 22:29:59 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Mon, 27 Jun 2011 22:40:12 GMT]]></title><description><![CDATA[<p>Hast du denn mal ein Beispiel für etwas, was zwar eine Memberfunktion, aber keine Methode (oder umgekehrt) ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2085163</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085163</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 27 Jun 2011 22:40:12 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Mon, 27 Jun 2011 22:45:57 GMT]]></title><description><![CDATA[<p>Dieses Beispiel kann es nicht geben. C++ hat keine Methoden, genauso wie andere Sprachen keine Memberfunktionen haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2085166</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085166</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Mon, 27 Jun 2011 22:45:57 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Mon, 27 Jun 2011 22:50:09 GMT]]></title><description><![CDATA[<p>314159265358979 schrieb:</p>
<blockquote>
<p>Dieses Beispiel kann es nicht geben. C++ hat keine Methoden, genauso wie andere Sprachen keine Memberfunktionen haben.</p>
</blockquote>
<p>Aus welchem Buch hast Du das? (Für die Blacklist)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2085170</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085170</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 27 Jun 2011 22:50:09 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Mon, 27 Jun 2011 22:57:13 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> Ich suche mal den Artikel, kleinen Moment.</p>
<p>Edit: Yay, gefunden! <a href="http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum=544" rel="nofollow">Klick</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2085171</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085171</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Mon, 27 Jun 2011 22:57:13 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Mon, 27 Jun 2011 23:10:56 GMT]]></title><description><![CDATA[<p>314159265358979 schrieb:</p>
<blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> Ich suche mal den Artikel, kleinen Moment.</p>
<p>Edit: Yay, gefunden! <a href="http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum=544" rel="nofollow">Klick</a></p>
</blockquote>
<p>Er redet irre. Gibt es eigentlich static member functions, also member functions, die keinen geheimen this-Pointer übergeben bekommen? Sind das danbn Methoden?</p>
<p>Es ist nicht notwendig, ein neues Wort zu erfinden, nur um auf ein Implementierungsdetail von C++ hinzuweisen, zumal genau dieses Detail im Standard nicht garantiert wird und C++-Member-Functions innendrin doch genauso funktionieren könnten wie Methoden in Eiffel oder Java.</p>
<p>Leider spricht er englich, das macht ihn unglaublich glaubwürdig.<br />
Daher kopiere ich mal den ersten commment:</p>
<blockquote>
<p>First of all. After compilation all code is transformed into assembly, which is raw machine code with no human-friendly structure.</p>
<p>That said, why are you looking at the implementation of the concept after we hit the &quot;compile&quot; button?</p>
<p>In my opinion, you're clearly confusing the OO concept, with the way it is implemented.</p>
<p>The concept of a property is a characteristic of an object. A method, is simply it's action. In what sense member function are not methods and data members are not properties?</p>
<p>Ok, we do have more fancy implemetations in other languages, but their implementations mostly implement syntax suggars, optimization techniques or even have other concerns like reflection support.</p>
<p>This remember me a classical question my teacher asked me in the computer science course, several years ago: &quot;What is the difference between polymorphism and virtual methods?&quot;</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2085175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085175</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 27 Jun 2011 23:10:56 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Tue, 28 Jun 2011 08:50:19 GMT]]></title><description><![CDATA[<p>314159265358979 schrieb:</p>
<blockquote>
<p>C++ kennt keine Methoden, nur Memberfunktionen!</p>
</blockquote>
<p>Keine Methoden im Sinne von irgendwelchen abstrakt gehaltenen Definitionen einzelner Autoren von Büchern über OOP-Konzepte. Was im hiesigen Kontext völlig irrelevant ist. Du darfst es dir so vorstellen, dass im C++-Kontext die allgemein anerkannte Definition der C++-Community (Methode = Memberfunktion) mehr wiegt als die von irgendwelchen provokanten Artikeln, die du in der letzten Woche gelesen hast. Natürlich weißt du das, ich geh mal davon aus, dass du nicht ganz so ignorant bist, wie du dich manchmal gibst, sondern wie üblich nur provozieren möchtest.<br />
Deshalb bitte back to topic.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2085276</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085276</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 28 Jun 2011 08:50:19 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Tue, 28 Jun 2011 08:56:09 GMT]]></title><description><![CDATA[<p>Wahrscheinlich wurde er im ##C++ Channel auf Freenode für &quot;Methode&quot; geflamed... die machen das nämlich verdammt gerne :D.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2085281</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085281</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Tue, 28 Jun 2011 08:56:09 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse - Methodendeklaration on Tue, 28 Jun 2011 16:25:29 GMT]]></title><description><![CDATA[<p>Quakenet ftw <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Und ja, B2T. &lt;.&lt;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2085545</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085545</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Tue, 28 Jun 2011 16:25:29 GMT</pubDate></item></channel></rss>