<?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 Katze - gelöst]]></title><description><![CDATA[<p>Hallo und guten Abend liebe Gemeinde.</p>
<p>Ich wollte folgenden Programmcode schreiben:</p>
<pre><code class="language-cpp">#pragma once
#include &lt;string&gt;
using namespace std;

class Katze
{
private:
  string Name;
  int Alter;
  int Gewicht;

public:
  Katze();
  ~Katze();

  string getName();
  int getAlter();
  int getGewicht();

  void setName();
  void setAlter();
  void setGewicht();
};

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;Klasse Katze.h&quot;
using namespace std;

Katze::Katze()
{

}

Katze::~Katze()
{

}

string Katze::getName()
{
  return Name;
}

int Katze::getAlter()
{
  return Alter;
}

int Katze::getGewicht()
{
  return Gewicht;
}

void Katze::setAlter(int age)
{
  Alter = age;
}

void Katze::setName(string name)
{
  Name = name;
}

void Katze::setGewicht(int weight)
{
  Gewicht = weight;
}

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;Klasse Katze.h&quot;
using namespace std;

int main()
{
  Katze Frisky;

  Frisky.setName(Maxi)
  Frisky.setAlter(1);
  Frisky.setGewicht(2);

  cout &lt;&lt; &quot;Name der Katze: &quot; &lt;&lt; Frisky.getName() &lt;&lt; &quot;\n&quot;;
  cout &lt;&lt; &quot;Alter der Katze: &quot; &lt;&lt; Frisky.getAlter() &lt;&lt; &quot;\n&quot;;
  cout &lt;&lt; &quot;Gewicht der Katze: &quot; &lt;&lt; Frisky.getGewicht() &lt;&lt; &quot;\n&quot;;

  cout &lt;&lt; &quot;\n&quot;;
  cout &lt;&lt; &quot;\n&quot;;
  cout &lt;&lt; &quot;Fuenf Jahre spaeter\n&quot;;
  cout &lt;&lt; &quot;\n&quot;;
  cout &lt;&lt; &quot;\n&quot;;

  Frisky.setAlter(6);
  Frisky.setGewicht(8);

  cout &lt;&lt; Frisky.getName() &lt;&lt; &quot; ist jetzt &quot; &lt;&lt; Frisky.getAlter() &lt;&lt; &quot;Jahre alt!\n&quot;;
  cout &lt;&lt; Frisky.getName() &lt;&lt; &quot; wiegt jetzt &quot; &lt;&lt; Frisky.getGewicht() &lt;&lt; &quot;kg!\n&quot;;

  return 0;
}
</code></pre>
<p>In Zeile 80 wird bei mir jedoch der Name &quot;Maxi&quot; rot unterringelt mit der Meldung</p>
<pre><code class="language-cpp">Error: Der Bezeichner &quot;Maxi&quot; ist nicht definiert
</code></pre>
<p>Woran liegt das? Was habe ich falsch gemacht?</p>
<p>Danke für die Antworten im Voraus.</p>
<p>Gruß</p>
<p>Max</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/314180/klasse-katze-gelöst</link><generator>RSS for Node</generator><lastBuildDate>Sat, 01 Aug 2026 11:05:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/314180.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 22 Feb 2013 18:44:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 18:57:21 GMT]]></title><description><![CDATA[<p>Hallo und guten Abend liebe Gemeinde.</p>
<p>Ich wollte folgenden Programmcode schreiben:</p>
<pre><code class="language-cpp">#pragma once
#include &lt;string&gt;
using namespace std;

class Katze
{
private:
  string Name;
  int Alter;
  int Gewicht;

public:
  Katze();
  ~Katze();

  string getName();
  int getAlter();
  int getGewicht();

  void setName();
  void setAlter();
  void setGewicht();
};

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;Klasse Katze.h&quot;
using namespace std;

Katze::Katze()
{

}

Katze::~Katze()
{

}

string Katze::getName()
{
  return Name;
}

int Katze::getAlter()
{
  return Alter;
}

int Katze::getGewicht()
{
  return Gewicht;
}

void Katze::setAlter(int age)
{
  Alter = age;
}

void Katze::setName(string name)
{
  Name = name;
}

void Katze::setGewicht(int weight)
{
  Gewicht = weight;
}

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;Klasse Katze.h&quot;
using namespace std;

int main()
{
  Katze Frisky;

  Frisky.setName(Maxi)
  Frisky.setAlter(1);
  Frisky.setGewicht(2);

  cout &lt;&lt; &quot;Name der Katze: &quot; &lt;&lt; Frisky.getName() &lt;&lt; &quot;\n&quot;;
  cout &lt;&lt; &quot;Alter der Katze: &quot; &lt;&lt; Frisky.getAlter() &lt;&lt; &quot;\n&quot;;
  cout &lt;&lt; &quot;Gewicht der Katze: &quot; &lt;&lt; Frisky.getGewicht() &lt;&lt; &quot;\n&quot;;

  cout &lt;&lt; &quot;\n&quot;;
  cout &lt;&lt; &quot;\n&quot;;
  cout &lt;&lt; &quot;Fuenf Jahre spaeter\n&quot;;
  cout &lt;&lt; &quot;\n&quot;;
  cout &lt;&lt; &quot;\n&quot;;

  Frisky.setAlter(6);
  Frisky.setGewicht(8);

  cout &lt;&lt; Frisky.getName() &lt;&lt; &quot; ist jetzt &quot; &lt;&lt; Frisky.getAlter() &lt;&lt; &quot;Jahre alt!\n&quot;;
  cout &lt;&lt; Frisky.getName() &lt;&lt; &quot; wiegt jetzt &quot; &lt;&lt; Frisky.getGewicht() &lt;&lt; &quot;kg!\n&quot;;

  return 0;
}
</code></pre>
<p>In Zeile 80 wird bei mir jedoch der Name &quot;Maxi&quot; rot unterringelt mit der Meldung</p>
<pre><code class="language-cpp">Error: Der Bezeichner &quot;Maxi&quot; ist nicht definiert
</code></pre>
<p>Woran liegt das? Was habe ich falsch gemacht?</p>
<p>Danke für die Antworten im Voraus.</p>
<p>Gruß</p>
<p>Max</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301152</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301152</guid><dc:creator><![CDATA[silent_max]]></dc:creator><pubDate>Fri, 22 Feb 2013 18:57:21 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 18:48:23 GMT]]></title><description><![CDATA[<blockquote>
<p>Frisky.setName(Maxi)</p>
</blockquote>
<p>=&gt;</p>
<blockquote>
<p>Frisky.setName(&quot;Maxi&quot;);</p>
</blockquote>
<p>Strichpunkt und &quot;&quot; vergessen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301155</guid><dc:creator><![CDATA[kleiner Troll]]></dc:creator><pubDate>Fri, 22 Feb 2013 18:48:23 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 18:52:20 GMT]]></title><description><![CDATA[<p>Danke... den Strichpunkt habe ich echt nicht mehr gesehen...</p>
<p>Aber warum muss der Name Maxi in Gänsefüsschen? Ich dachte, dass die setter Funktion das schon kapiert...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301158</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301158</guid><dc:creator><![CDATA[silent_max]]></dc:creator><pubDate>Fri, 22 Feb 2013 18:52:20 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 18:53:19 GMT]]></title><description><![CDATA[<p>Die setter Funktion will einen String.<br />
Strings stehen normalerweise in Anführungszeichen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301159</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Fri, 22 Feb 2013 18:53:19 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 18:56:49 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>Die setter Funktion will einen String.<br />
Strings stehen normalerweise in Anführungszeichen.</p>
</blockquote>
<p>Ich Blödmann ... jetzt wo Du es gesagt hast, ist es mir wieder eingefallen, dass Strings in Anführungszeichen müssen...</p>
<p>Ich Vollpfosten... *Kopf gegen die Wand schlag*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301161</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301161</guid><dc:creator><![CDATA[silent_max]]></dc:creator><pubDate>Fri, 22 Feb 2013 18:56:49 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 19:10:38 GMT]]></title><description><![CDATA[<p>Noch ein kleiner Hinweis den du im Hinterkopf behalten solltest:<br />
Normalerweise solltest du Name, Alter etc bereits im Konstruktor von Katze setzen:</p>
<pre><code>Katze::Katze(string name, int alter, int gewicht) 
{
Name = name;
Alter = alter;
Gewicht = gewicht;
}
</code></pre>
<p>Noch besser (vermute aber der syntax wäre dir neu):</p>
<pre><code>Katze::Katze(const string&amp; name, int alter, int gewicht) : Name(name), Alter(alter), Gewicht(gewicht) 
{
}
</code></pre>
<p>Die Idee ist, das nach der Konstruktion &quot;Katze&quot; schon alle richtigen Werte hat, und man nicht vergessen kann einen Wert per set anzugeben - da würde dann nämlich der compiler jammern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301166</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301166</guid><dc:creator><![CDATA[kleiner Troll]]></dc:creator><pubDate>Fri, 22 Feb 2013 19:10:38 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 19:20:22 GMT]]></title><description><![CDATA[<p>silent_max schrieb:</p>
<blockquote>
<p>Nathan schrieb:</p>
<blockquote>
<p>Die setter Funktion will einen String.<br />
Strings stehen normalerweise in Anführungszeichen.</p>
</blockquote>
<p>Ich Blödmann ... jetzt wo Du es gesagt hast, ist es mir wieder eingefallen, dass Strings in Anführungszeichen müssen</p>
</blockquote>
<p>Konntest Du nicht wissen, bist ja erst ein Jahr dabei. Da kann man auch noch nicht die Fehlermeldungen des Compilers interpretieren.<br />
Macht aber nix, genau für solche Fälle gibt es ja dieses Forum.</p>
<p>SCNR</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301168</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301168</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Fri, 22 Feb 2013 19:20:22 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 19:24:24 GMT]]></title><description><![CDATA[<p>Eine klasse Katze! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301170</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301170</guid><dc:creator><![CDATA[topcode]]></dc:creator><pubDate>Fri, 22 Feb 2013 19:24:24 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 19:30:40 GMT]]></title><description><![CDATA[<p>kleiner Troll schrieb:</p>
<blockquote>
<blockquote>
<p>Frisky.setName(Maxi)</p>
</blockquote>
<p>=&gt;</p>
<blockquote>
<p>Frisky.setName(&quot;Maxi&quot;);</p>
</blockquote>
<p>Strichpunkt und &quot;&quot; vergessen.</p>
</blockquote>
<p>Härtner können zu Karneval auch nehmen</p>
<pre><code>#define STR(x) #x
...
Frisky.setName(STR(Maxi));
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2301171</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301171</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 22 Feb 2013 19:30:40 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 19:47:57 GMT]]></title><description><![CDATA[<p>Warum sind die getter eigentlich nicht const? Und warum ist das Alter und Gewicht Vorzeichenbehaftet, also int statt unsigned? Willst Du auch zukünftige Katzen unterstützen? Dann wäre das Alter momentan negativ <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="😉"
    /> . Aber was sind dann Katzen mit einem negativen Gewicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301177</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301177</guid><dc:creator><![CDATA[tntnet]]></dc:creator><pubDate>Fri, 22 Feb 2013 19:47:57 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 19:58:49 GMT]]></title><description><![CDATA[<p>tntnet schrieb:</p>
<blockquote>
<p>Warum sind die getter eigentlich nicht const?</p>
</blockquote>
<p>Ok, ein Versehen.</p>
<p>tntnet schrieb:</p>
<blockquote>
<p>Und warum ist das Alter und Gewicht Vorzeichenbehaftet, also int statt unsigned?</p>
</blockquote>
<p>Um es nicht zu übertreiben.</p>
<p>tntnet schrieb:</p>
<blockquote>
<p>Willst Du auch zukünftige Katzen unterstützen? Dann wäre das Alter momentan negativ <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>
</blockquote>
<p>Naja, wir wissen beide, daß &quot;Alter&quot; nicht so geschickt ist wie &quot;Geburtstag&quot;. Man würde nur an Fehlern weiterfehlen.</p>
<p>tntnet schrieb:</p>
<blockquote>
<p>Aber was sind dann Katzen mit einem negativen Gewicht?</p>
</blockquote>
<p>Naja, wir wissen beide, daß &quot;Gewicht&quot; nicht so geschickt ist wie &quot;Masse&quot;. Man würde nur an Fehlern weiterfehlen. Und die Masse sollte double sein. unsigned double gibt es ja noch nicht.</p>
<p>Wenn nicht VOLLKOMMEN klar, daß eine andere Skalierung vom Leser-Programmierer(der nicht unbedingt Fachmann für Tierärztliche Norm-Bestimmungen ist) angenommen wird, würde ich physikalische Messgrößen immer in SI-Einheiten angeben.<br />
double Masse ist also in Kilogramm.<br />
Will man abweichen, dann<br />
int MasseInGramm<br />
oder<br />
double MasseInGramm<br />
.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301181</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301181</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 22 Feb 2013 19:58:49 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 21:13:58 GMT]]></title><description><![CDATA[<blockquote>
<p>Tierärztliche</p>
</blockquote>
<p>Was hat das ganze mit Tierärzten zu tun?</p>
<blockquote>
<pre><code>double MasseInGramm
</code></pre>
</blockquote>
<p>Sicher hat das einen anderen Grund, aber ROFL, willst du die Katze auf das Pikogramm genau wiegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301220</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Fri, 22 Feb 2013 21:13:58 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Fri, 22 Feb 2013 21:49:55 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<blockquote>
<p>Tierärztliche</p>
</blockquote>
<p>Was hat das ganze mit Tierärzten zu tun?</p>
</blockquote>
<p>Wer misst sonst regelmäßig Katzenmassen?</p>
<p>Sone schrieb:</p>
<blockquote>
<blockquote>
<pre><code>double MasseInGramm
</code></pre>
</blockquote>
<p>Sicher hat das einen anderen Grund, aber ROFL, willst du die Katze auf das Pikogramm genau wiegen?</p>
</blockquote>
<p>Sobald man double benutzt, ist es wurstegal, ob man in Gramm, Kilogramm, Tonnen, Kilotonnen oder sonstwas mißt. Darum bevorzuge ich Kilogramm. Aber das ist nur eine leichte Bevorzugung. Wenns bei den Tierbenutzern (darf ja nicht mehr Tierärzte sagen) voll üblicher ist, Gramm zu nehmen, dann halt in Gramm. Das ist für mich aber NUR eine Frage der Benutzerschnittstelle.<br />
Würde mich ungern auf int festlegen da, weil bestimmt irgendwann Waagen auftauchen, die auf halbe Gramm messen. Zum Beispiel hier meine Dope-Waage. Mit der würde ich einen Hamster wäägen. Und sie zeigt in Gramm Nachkommastellen an. Warum sollte die Software nicht erlauben, daß man die auch erfasst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301232</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301232</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 22 Feb 2013 21:49:55 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Sat, 23 Feb 2013 07:45:49 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>Sone schrieb:</p>
<blockquote>
<blockquote>
<p>Tierärztliche</p>
</blockquote>
<p>Was hat das ganze mit Tierärzten zu tun?</p>
</blockquote>
<p>Wer misst sonst regelmäßig Katzenmassen?</p>
</blockquote>
<p>Chinesische Köche.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301260</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301260</guid><dc:creator><![CDATA[MiauZeTung]]></dc:creator><pubDate>Sat, 23 Feb 2013 07:45:49 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse Katze - gelöst on Sat, 23 Feb 2013 07:53:26 GMT]]></title><description><![CDATA[<p>Tierbenutzern <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="😃"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
<p>MiauZeTung schrieb:</p>
<blockquote>
<p>volkard schrieb:</p>
<blockquote>
<p>Sone schrieb:</p>
<blockquote>
<blockquote>
<p>Tierärztliche</p>
</blockquote>
<p>Was hat das ganze mit Tierärzten zu tun?</p>
</blockquote>
<p>Wer misst sonst regelmäßig Katzenmassen?</p>
</blockquote>
<p>Chinesische Köche.</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f60b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_savoring_food"
      title=":yum:"
      alt="😋"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
<blockquote>
<p>Mit der würde ich einen Hamster wäägen</p>
</blockquote>
<p>Du meinst wiegen? ^^</p>
<p>kk, du hast schon Recht, es macht schon Sinn.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2301261</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2301261</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sat, 23 Feb 2013 07:53:26 GMT</pubDate></item></channel></rss>