<?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[Hilfe bei Fehlersuche C++ (Klasse)]]></title><description><![CDATA[<p>Hallo @all;</p>
<p>ich bin dabei C++ zu lernen,habe gerade ein kleines Programm (Kasse) geschrieben,aber in der <strong>main Datei</strong> in Fehler drin,den ich nicht finde,kann Jemand mir helfen?</p>
<blockquote>
<p>#include &lt;iostream.&gt;<br />
using namespace std;</p>
<p>class Point<br />
{<br />
private:<br />
int x;<br />
int y;<br />
public:<br />
int getx() { return x; }<br />
int gety() { return y; }<br />
void setx(int x);<br />
void sety(int y);</p>
<p>};</p>
<p>void Point::setx(int x)<br />
{ x = 2; }<br />
void Point::sety(int y)<br />
{ y = 3; }</p>
<p>**int main()<br />
{<br />
Point A;</p>
<p>A.setx();<br />
cout &lt;&lt;A.getx()&lt;&lt;endl;<br />
A.sety();<br />
cout&lt;&lt;A.gety()&lt;&lt;endl;**</p>
<p>system(&quot;PAUSE&quot;);<br />
return EXIT_SUCCESS;<br />
}</p>
</blockquote>
<p>Wie soll in main() Datei aussehen?</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/170291/hilfe-bei-fehlersuche-c-klasse</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 00:57:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/170291.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 14 Jan 2007 09:49:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hilfe bei Fehlersuche C++ (Klasse) on Sun, 14 Jan 2007 09:49:43 GMT]]></title><description><![CDATA[<p>Hallo @all;</p>
<p>ich bin dabei C++ zu lernen,habe gerade ein kleines Programm (Kasse) geschrieben,aber in der <strong>main Datei</strong> in Fehler drin,den ich nicht finde,kann Jemand mir helfen?</p>
<blockquote>
<p>#include &lt;iostream.&gt;<br />
using namespace std;</p>
<p>class Point<br />
{<br />
private:<br />
int x;<br />
int y;<br />
public:<br />
int getx() { return x; }<br />
int gety() { return y; }<br />
void setx(int x);<br />
void sety(int y);</p>
<p>};</p>
<p>void Point::setx(int x)<br />
{ x = 2; }<br />
void Point::sety(int y)<br />
{ y = 3; }</p>
<p>**int main()<br />
{<br />
Point A;</p>
<p>A.setx();<br />
cout &lt;&lt;A.getx()&lt;&lt;endl;<br />
A.sety();<br />
cout&lt;&lt;A.gety()&lt;&lt;endl;**</p>
<p>system(&quot;PAUSE&quot;);<br />
return EXIT_SUCCESS;<br />
}</p>
</blockquote>
<p>Wie soll in main() Datei aussehen?</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1209538</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1209538</guid><dc:creator><![CDATA[Wera]]></dc:creator><pubDate>Sun, 14 Jan 2007 09:49:43 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Fehlersuche C++ (Klasse) on Sun, 14 Jan 2007 09:52:36 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=18363" rel="nofollow">Jochen Kalmbach</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=58" rel="nofollow">C++/CLI mit .NET</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1209540</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1209540</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Sun, 14 Jan 2007 09:52:36 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Fehlersuche C++ (Klasse) on Sun, 14 Jan 2007 10:10:59 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>wenn du das nächste mal postetst, bitte gib die exakte Fehlermeldung und die Zeile, wo der Fehler auftrat an. Weil so weiß keiner, WAS nicht korrekt läuft und WIE es funktionieren sollte.<br />
Das einzige, was mir spontan auffällt, ist: Du nimmst zwar Parameter bei setx und sety entgegen (die sollten im Übrigen nicht x und y heißen. So heißen schon deine Attribute in der Point Klasse), jedoch benutzt du sie nicht, sondern weist ihnen irgendwas zu.<br />
Außerdem gibst du den Methoden beim Aufruf in main keinen Wert mit.</p>
<p>Korrekt wäre also:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;

class Point
{
  int x;
  int y;
public:
  int getx() { return x; }
  int gety() { return y; }
  void setx(int);  //hier kannst du dir die Angabe des Namens sparen
  void sety(int);
};

void Point::setx(int val)  { x = val; }
void Point::sety(int val)  { y = val; }

int main()
{
Point a;

a.setx(2);
a.sety(3);

cout&lt;&lt;a.getx()&lt;&lt;endl;
cout&lt;&lt;a.gety()&lt;&lt;endl;

//system(&quot;PAUSE&quot;);  Das ist böse. Bitte weglassen.
return EXIT_SUCCESS;
}
</code></pre>
<p>system(&quot;PAUSE&quot;) kann man ersetzen, lies hier: <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-111042.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-111042.html</a></p>
<p>MfG</p>
<p>GPC</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1209550</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1209550</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Sun, 14 Jan 2007 10:10:59 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Fehlersuche C++ (Klasse) on Sun, 14 Jan 2007 12:03:45 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6287">@GPC</a></p>
<p>Danke dir,habe was gelernt,das war der Fehler.</p>
<p>Gruss<br />
Wera</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1209606</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1209606</guid><dc:creator><![CDATA[Wera]]></dc:creator><pubDate>Sun, 14 Jan 2007 12:03:45 GMT</pubDate></item></channel></rss>