<?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 für einen Anfänger]]></title><description><![CDATA[<p>hallo Leute</p>
<p>ich muss für die schule einen sparschwein Programmieren. Die Header datei müsste fehlerfrei sein ...mein problem ist die cpp datei</p>
<p>der compiler gibt zwar keine fehler an und führt die exe datei aus aber die exe datei gibt sofort ein Fehler aus ....&quot;piggybank.exe hat ein fehler festgestellt usw&quot;</p>
<p>wenn mir da jemand mal sagen könnte wo das problem liegt wär ich sehr dankbar.</p>
<p>Desweiteren würd ich doch gern noch paar änderungen an meiner main funktion vornehmen ...so wie es jetzt ist ....gibt er immer eine vorgeschriebene anzahl an münzen in das sparschwein und zieht wieder welche ab. Meine vorstellung ist</p>
<p>er soll max. 50 Münzen zulassen<br />
dan den inhalt ausgeben isBroken()<br />
ob er voll isFull() oder Leer ist isEmpty() anzeigen.</p>
<p>header datei:</p>
<pre><code class="language-cpp">//piggybank.h

#ifndef PIGGYBANK_H
#define PIGGYBANK_H

class PiggyBank
{
public:
    PiggyBank(int _1cent = 0, int _10cent = 0, int _50cent = 0, int _1euro = 0);

    int get1centsCount();
    int get10centsCount();
    int get50centsCount();
    int get1eurosCount();

    PiggyBank &amp;add1cents(int );
    PiggyBank &amp;add10cents(int );
    PiggyBank &amp;add50cents(int );
    PiggyBank &amp;add1euros(int );

    int withdraw1cents(int );
    int withdraw10cents(int );
    int withdraw50cents(int );
    int withdraw1euros(int );

    double displayBalance();
    void isEmpty();
    void isFull();
    void isBroken();
    void breakInto();

public:
    int _1cent;
    int _10cent;
    int _50cent;
    int _1euro;

} ;
#endif
</code></pre>
<p>cpp datei</p>
<pre><code class="language-cpp">//PiggyBank.cpp
#include &lt;cstdlib&gt;
#include&lt;iostream&gt;
#include &quot;piggybank.h&quot;

using namespace std;

PiggyBank::PiggyBank(int _1cent, int _10cent, int _50cent, int _1euro)
{
    add1cents(_1cent);
    add10cents(_10cent);
    add50cents(_50cent);
    add1euros(_1euro);
}

PiggyBank &amp;PiggyBank::add1cents(int p)
{
    _1cent = _1cent + p;
}

PiggyBank &amp;PiggyBank::add10cents(int n)
{
    _10cent = _10cent + n;
}

PiggyBank &amp;PiggyBank::add50cents(int d)
{
    _50cent = _50cent + d;
}

PiggyBank &amp;PiggyBank::add1euros(int q)
{
    _1euro = _1euro + q;
}

int PiggyBank::get1centsCount()
{
    return _1cent;
}

int PiggyBank::get10centsCount()
{
    return _10cent;
}

int PiggyBank::get50centsCount()
{
    return _50cent;
}

int PiggyBank::get1eurosCount()
{
    return _1euro;
}

int PiggyBank::withdraw1cents(int p)
{
    _1cent = _1cent - p;
}

int PiggyBank::withdraw10cents(int n)
{
    _10cent = _10cent - n;
}

int PiggyBank::withdraw50cents(int d)
{
    _50cent = _50cent - d;
}

int PiggyBank::withdraw1euros(int q)
{
    _1euro = _1euro - q;
}

double PiggyBank::displayBalance()
{
    double balance = (_1euro * 1) + (_50cent * .50) + (_10cent * .1) + (_1cent * .01);
    return balance;

}

void PiggyBank::isEmpty()
{
}
void PiggyBank::isFull()
{
}
void PiggyBank::isBroken()
{
}
void PiggyBank::breakInto()
{
}

int main()
{
    PiggyBank leer;
    cout &lt;&lt; &quot;(1) Sparschwein ist LEER!! &quot;;
    //leer.displayBalance();
    //cout &lt;&lt; endl;

    //leer.add1cents(17).add10cents(6).add50cents(3).add1euros(5);
    cout &lt;&lt; &quot;(2) Sparschwein ist befüllt! &quot;;
    leer.displayBalance();
    cout &lt;&lt; endl;

    cout &lt;&lt; &quot;(3) ziehe 4 10cent Münzen ab &quot;
        &lt;&lt; leer.withdraw10cents(4) &lt;&lt; &quot; jetzt sind nur noch &quot;;
    leer.displayBalance();
    cout &lt;&lt; endl
        &lt;&lt; leer.get10centsCount()
        &lt;&lt; &quot; im Sparschwein&quot; &lt;&lt; endl;

    cout &lt;&lt; &quot;(4) ziehe 5 50cent Münzen ab &quot;
        &lt;&lt; leer.withdraw50cents(5) &lt;&lt; &quot; jetzt sind nur noch &quot;;
    leer.displayBalance();
    cout &lt;&lt; endl
        &lt;&lt; leer.get50centsCount()
        &lt;&lt; &quot; im sparschwein&quot; &lt;&lt; endl;

    leer.add50cents(2).add1euros(-1);
    cout &lt;&lt; &quot;(5) werfe 2 50cent Münzen ein und ziehe eine 1euro Münze ab, &quot;
        &lt;&lt; &quot; jetzt sind im &quot;;
    leer.displayBalance();
    cout &lt;&lt; endl
        &lt;&lt; leer.get50centsCount()
        &lt;&lt; leer.get1eurosCount()
        &lt;&lt; &quot; Sparschwein &quot; &lt;&lt; endl;

    cout &lt;&lt; &quot;(6) &quot;;
    leer.breakInto();
    cout &lt;&lt; &quot;  das Sparschwein enthält &quot;;
    leer.displayBalance();
    cout &lt;&lt; endl;

system(&quot;PAUSE&quot;);
return 0;
}
</code></pre>
<p>mfg carsi</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/240418/hilfe-für-einen-anfänger</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 00:03:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/240418.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 06 May 2009 13:15:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Wed, 06 May 2009 13:15:21 GMT]]></title><description><![CDATA[<p>hallo Leute</p>
<p>ich muss für die schule einen sparschwein Programmieren. Die Header datei müsste fehlerfrei sein ...mein problem ist die cpp datei</p>
<p>der compiler gibt zwar keine fehler an und führt die exe datei aus aber die exe datei gibt sofort ein Fehler aus ....&quot;piggybank.exe hat ein fehler festgestellt usw&quot;</p>
<p>wenn mir da jemand mal sagen könnte wo das problem liegt wär ich sehr dankbar.</p>
<p>Desweiteren würd ich doch gern noch paar änderungen an meiner main funktion vornehmen ...so wie es jetzt ist ....gibt er immer eine vorgeschriebene anzahl an münzen in das sparschwein und zieht wieder welche ab. Meine vorstellung ist</p>
<p>er soll max. 50 Münzen zulassen<br />
dan den inhalt ausgeben isBroken()<br />
ob er voll isFull() oder Leer ist isEmpty() anzeigen.</p>
<p>header datei:</p>
<pre><code class="language-cpp">//piggybank.h

#ifndef PIGGYBANK_H
#define PIGGYBANK_H

class PiggyBank
{
public:
    PiggyBank(int _1cent = 0, int _10cent = 0, int _50cent = 0, int _1euro = 0);

    int get1centsCount();
    int get10centsCount();
    int get50centsCount();
    int get1eurosCount();

    PiggyBank &amp;add1cents(int );
    PiggyBank &amp;add10cents(int );
    PiggyBank &amp;add50cents(int );
    PiggyBank &amp;add1euros(int );

    int withdraw1cents(int );
    int withdraw10cents(int );
    int withdraw50cents(int );
    int withdraw1euros(int );

    double displayBalance();
    void isEmpty();
    void isFull();
    void isBroken();
    void breakInto();

public:
    int _1cent;
    int _10cent;
    int _50cent;
    int _1euro;

} ;
#endif
</code></pre>
<p>cpp datei</p>
<pre><code class="language-cpp">//PiggyBank.cpp
#include &lt;cstdlib&gt;
#include&lt;iostream&gt;
#include &quot;piggybank.h&quot;

using namespace std;

PiggyBank::PiggyBank(int _1cent, int _10cent, int _50cent, int _1euro)
{
    add1cents(_1cent);
    add10cents(_10cent);
    add50cents(_50cent);
    add1euros(_1euro);
}

PiggyBank &amp;PiggyBank::add1cents(int p)
{
    _1cent = _1cent + p;
}

PiggyBank &amp;PiggyBank::add10cents(int n)
{
    _10cent = _10cent + n;
}

PiggyBank &amp;PiggyBank::add50cents(int d)
{
    _50cent = _50cent + d;
}

PiggyBank &amp;PiggyBank::add1euros(int q)
{
    _1euro = _1euro + q;
}

int PiggyBank::get1centsCount()
{
    return _1cent;
}

int PiggyBank::get10centsCount()
{
    return _10cent;
}

int PiggyBank::get50centsCount()
{
    return _50cent;
}

int PiggyBank::get1eurosCount()
{
    return _1euro;
}

int PiggyBank::withdraw1cents(int p)
{
    _1cent = _1cent - p;
}

int PiggyBank::withdraw10cents(int n)
{
    _10cent = _10cent - n;
}

int PiggyBank::withdraw50cents(int d)
{
    _50cent = _50cent - d;
}

int PiggyBank::withdraw1euros(int q)
{
    _1euro = _1euro - q;
}

double PiggyBank::displayBalance()
{
    double balance = (_1euro * 1) + (_50cent * .50) + (_10cent * .1) + (_1cent * .01);
    return balance;

}

void PiggyBank::isEmpty()
{
}
void PiggyBank::isFull()
{
}
void PiggyBank::isBroken()
{
}
void PiggyBank::breakInto()
{
}

int main()
{
    PiggyBank leer;
    cout &lt;&lt; &quot;(1) Sparschwein ist LEER!! &quot;;
    //leer.displayBalance();
    //cout &lt;&lt; endl;

    //leer.add1cents(17).add10cents(6).add50cents(3).add1euros(5);
    cout &lt;&lt; &quot;(2) Sparschwein ist befüllt! &quot;;
    leer.displayBalance();
    cout &lt;&lt; endl;

    cout &lt;&lt; &quot;(3) ziehe 4 10cent Münzen ab &quot;
        &lt;&lt; leer.withdraw10cents(4) &lt;&lt; &quot; jetzt sind nur noch &quot;;
    leer.displayBalance();
    cout &lt;&lt; endl
        &lt;&lt; leer.get10centsCount()
        &lt;&lt; &quot; im Sparschwein&quot; &lt;&lt; endl;

    cout &lt;&lt; &quot;(4) ziehe 5 50cent Münzen ab &quot;
        &lt;&lt; leer.withdraw50cents(5) &lt;&lt; &quot; jetzt sind nur noch &quot;;
    leer.displayBalance();
    cout &lt;&lt; endl
        &lt;&lt; leer.get50centsCount()
        &lt;&lt; &quot; im sparschwein&quot; &lt;&lt; endl;

    leer.add50cents(2).add1euros(-1);
    cout &lt;&lt; &quot;(5) werfe 2 50cent Münzen ein und ziehe eine 1euro Münze ab, &quot;
        &lt;&lt; &quot; jetzt sind im &quot;;
    leer.displayBalance();
    cout &lt;&lt; endl
        &lt;&lt; leer.get50centsCount()
        &lt;&lt; leer.get1eurosCount()
        &lt;&lt; &quot; Sparschwein &quot; &lt;&lt; endl;

    cout &lt;&lt; &quot;(6) &quot;;
    leer.breakInto();
    cout &lt;&lt; &quot;  das Sparschwein enthält &quot;;
    leer.displayBalance();
    cout &lt;&lt; endl;

system(&quot;PAUSE&quot;);
return 0;
}
</code></pre>
<p>mfg carsi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1706465</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706465</guid><dc:creator><![CDATA[carsi]]></dc:creator><pubDate>Wed, 06 May 2009 13:15:21 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Wed, 06 May 2009 13:29:15 GMT]]></title><description><![CDATA[<p>Also mein Compiler übersetzt das nicht. Du hast schonmal vergessen, bei den meisten deiner Methoden auch einen Wert zurückzugeben...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1706476</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706476</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Wed, 06 May 2009 13:29:15 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Wed, 06 May 2009 18:35:45 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile-var-mode-is-viewprofile-and-u-is-1819.html" rel="nofollow">rüdiger</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-8.html" rel="nofollow">Rund um die Programmierung</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-15.html" rel="nofollow">C++</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39405.html" 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/1706721</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706721</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Wed, 06 May 2009 18:35:45 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Thu, 07 May 2009 06:11:25 GMT]]></title><description><![CDATA[<p>danke erstmal für deine hilfe</p>
<p>noch bin ich nicht weiter gekommen aber ich experimmäntiere mal weiter ...und ich benutze DEV C++ als compiler</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1706868</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706868</guid><dc:creator><![CDATA[carsi]]></dc:creator><pubDate>Thu, 07 May 2009 06:11:25 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Thu, 07 May 2009 06:41:46 GMT]]></title><description><![CDATA[<p>carsi schrieb:</p>
<blockquote>
<p>...und ich benutze DEV C++ als compiler</p>
</blockquote>
<p>Wechsel lieber mal auf eine aktuelle Umgebung (DEV C++ ist dies nicht) wie Visual C++ 2008 Express oder Code::Blocks.</p>
<p>Wobei ich bezweifel das - unabhängig wie schlecht DEV C++ ist - du keine Warnungen bekommst. In 98% der Fälle sollte man auch Warnungen beachten... (und bei den verbleibenden 2% sollte man sich wirklich sicher sein, das diese keine Auswirkungen haben).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1706876</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706876</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Thu, 07 May 2009 06:41:46 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Thu, 07 May 2009 07:09:00 GMT]]></title><description><![CDATA[<p>ich bin auf DEV C++ angewiesen weil es das einzige programm auf den SCHULRECHNER ist leider. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1706890</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706890</guid><dc:creator><![CDATA[carsi]]></dc:creator><pubDate>Thu, 07 May 2009 07:09:00 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Thu, 07 May 2009 07:23:11 GMT]]></title><description><![CDATA[<p>carsi schrieb:</p>
<blockquote>
<p>ich bin auf DEV C++ angewiesen weil es das einzige programm auf den SCHULRECHNER ist leider. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
</blockquote>
<p>Dennoch bezweifel ich, das du nicht einmal eine Warnung bekommst. Beispielsweise für folgende Methode:</p>
<pre><code class="language-cpp">PiggyBank &amp; PiggyBank::add1cents(int p)
{
    _1cent = _1cent + p;
}
</code></pre>
<p>Selbst bei Compilern die dies ohne Fehlermeldung akzeptieren, kenne ich keinen, der nicht mindestens eine Warnung ausgeben würde.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1706893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706893</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Thu, 07 May 2009 07:23:11 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Thu, 07 May 2009 07:27:40 GMT]]></title><description><![CDATA[<p>wie gesagt bei mir in der zeile wo die fehler und meldungen ausgegeben werden steht nix ...aber wie müsste der code den aussehen deiner meinung nach?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1706896</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706896</guid><dc:creator><![CDATA[carsi]]></dc:creator><pubDate>Thu, 07 May 2009 07:27:40 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Thu, 07 May 2009 07:28:59 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">PiggyBank &amp;PiggyBank::add1cents(int p) 
{ 
    _1cent = _1cent + p; 
    return *this;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1706897</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706897</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 07 May 2009 07:28:59 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Thu, 07 May 2009 07:34:38 GMT]]></title><description><![CDATA[<p>.... und außerdem würde ich Dir vorschlagen, erst einmal<br />
1.) ein &quot;hello world&quot;-Programm zu kompilieren und erfolgreich laufen zu lassen und<br />
2.) dann langsam Dein Programm aufzubauen und nicht erstmal 30 (zudem noch nahezu identische) Memberfunktionen zu implementieren, wenn das Programm sowieso nicht läuft.<br />
3.) Schließlich ist &quot;leer&quot; ein selten dä...... &quot;ungewöhlicher&quot; Variablenname. Spätestens nach dem ersten &quot;add....&quot;-Call stimmt er schon nicht mehr.<br />
<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>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1706899</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706899</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Thu, 07 May 2009 07:34:38 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Thu, 07 May 2009 07:35:33 GMT]]></title><description><![CDATA[<p>Na wenn eine Funktion nix zurückgeben soll, dann musst du das auh so deklarieren (gib als Rückgabetyp void an).</p>
<p>carsi schrieb:</p>
<blockquote>
<p>wie gesagt bei mir in der zeile wo die fehler und meldungen<br />
ausgegeben werden steht nix</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /><br />
In welcher Zeile wird denn eine Fehlermeldung angezeigt? Und wieso soll da nix stehen??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1706902</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706902</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 07 May 2009 07:35:33 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Thu, 07 May 2009 08:16:53 GMT]]></title><description><![CDATA[<p>danke theta</p>
<p>jetzt kommt die debug fehlermeldung beim ausführen nicht mehr.<br />
Nun gibt er aber einfach irgendwelche langen zahlenketten aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1706918</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706918</guid><dc:creator><![CDATA[carsi]]></dc:creator><pubDate>Thu, 07 May 2009 08:16:53 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe für einen Anfänger on Thu, 07 May 2009 08:26:43 GMT]]></title><description><![CDATA[<p>_matze schrieb:</p>
<blockquote>
<p>in welcher Zeile wird denn eine Fehlermeldung angezeigt? Und wieso soll da nix stehen??</p>
</blockquote>
<p>du hast es falsch verstanden ....der compiler gibt keine fehlermeldung aus da für ihn keine fehler bestehen.....ich meinte damit das fenster wo mein compiler die fehler meldung vornimmt das da nix drin steht wo sich ASC sich gewundert hat das es halt keine Meldung Warnung gibt. <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>Die einzige fehler meldung kam beim Ausführen und das als WINDOWS Fehlermeldung die jetzt dank theta behoben ist</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1706922</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1706922</guid><dc:creator><![CDATA[carsi]]></dc:creator><pubDate>Thu, 07 May 2009 08:26:43 GMT</pubDate></item></channel></rss>