<?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[C++]]></title><description><![CDATA[<p>Ich hab in C++ ein Problem:<br />
Mein Programm:</p>
<p>#include &lt;iostream&gt;<br />
#include &lt;stdlib.h&gt;</p>
<p>using namespace std;<br />
class containerSchiff<br />
{<br />
private:<br />
int standOrt[3];<br />
int anzahlContainer[3];<br />
int kapazitaetContainer[3];<br />
int schiff[3];<br />
float preis_je_container[3];<br />
float gesamtUmsatz;</p>
<p>public:<br />
containerSchiff();<br />
~containerSchiff();<br />
void zeige_containerSchiff();<br />
void veraendere_containerSchiff();<br />
void belade_containerSchiff();<br />
void entlade_containerSchiff();<br />
void fahre_containerSchiff();<br />
int gebeStandOrt();<br />
};<br />
//------------------------------------------------------------------------------<br />
//Hauptprogramm<br />
int main(void)<br />
{<br />
containerSchiff container1;<br />
char wahl;<br />
int schiff[3];<br />
int standOrt[3];<br />
int anzahlContainer[3];<br />
int kapazitaetContainer[3];<br />
float preis_je_container[3];</p>
<p>int i;</p>
<p>cout&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Welches Schiff wollen sie bearbeiten?&quot;;<br />
cin&gt;&gt;i;<br />
cout&lt;&lt;endl;</p>
<p>while(wahl!='E')<br />
{<br />
cout&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Auswahl&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;========&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Containerschiff zeigen......1&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Containerschiff veraendern..2&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Containerschiff beladen.....3&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Containerschiff entladen....4&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Containerschiff fahren......5&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Standort geben..............6&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Ende........................E&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Wahl.......................:&quot;;<br />
cin&gt;&gt;wahl;</p>
<p>switch(wahl)<br />
{<br />
case '1': container1.zeige_containerSchiff();break;<br />
case '2': container1.veraendere_containerSchiff();break;<br />
case '3': container1.belade_containerSchiff();break;<br />
case '4': container1.entlade_containerSchiff();break;<br />
case '5': container1.fahre_containerSchiff();break;<br />
case '6': container1.gebeStandOrt();break;<br />
default: system(&quot;PAUSE&quot;);<br />
return 0;<br />
}</p>
<p>}</p>
<p>system(&quot;PAUSE&quot;);<br />
return 0;<br />
}//Ende Hauptprorgamm<br />
//------------------------------------------------------------------------------<br />
//Implementation der Elemente<br />
containerSchiff::containerSchiff()<br />
{<br />
int i;<br />
for(i=0;i&lt;3;i++)<br />
{<br />
cout&lt;&lt;&quot;Definieren Sie ihr Schiff&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Schiff[&quot;&lt;&lt;i&lt;&lt;&quot;]&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Standort: &quot;;<br />
cin&gt;&gt;standOrt[i];<br />
cout&lt;&lt;&quot;Anzahl Container: &quot;;<br />
cin&gt;&gt;anzahlContainer[i];<br />
cout&lt;&lt;&quot;Kapazitaet Container: &quot;;<br />
cin&gt;&gt;kapazitaetContainer[i];<br />
cout&lt;&lt;&quot;Preis je Container: &quot;;<br />
cin&gt;&gt;preis_je_container[i];<br />
}<br />
for(i=0;i&lt;3;i++)<br />
{<br />
cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Schiff:..............[&quot;&lt;&lt;i&lt;&lt;&quot;]&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Standort: &quot;&lt;&lt;standOrt[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Anzahl Container: &quot;&lt;&lt;anzahlContainer[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Kapazitaet Container: &quot;&lt;&lt;kapazitaetContainer[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Preis je Container: &quot;&lt;&lt;preis_je_container[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Gesamtumsatz:.........&quot;&lt;&lt;gesamtUmsatz&lt;&lt;endl;<br />
cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;</p>
<p>}<br />
}<br />
//------------------------------------------------------------------------------<br />
containerSchiff::~containerSchiff()<br />
{<br />
cout&lt;&lt;&quot;Destruktor&quot;&lt;&lt;endl;<br />
}<br />
//------------------------------------------------------------------------------<br />
void containerSchiff::zeige_containerSchiff()<br />
{<br />
float gesamtUmsatz=0;<br />
int i;</p>
<p>cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Schiff:..............[&quot;&lt;&lt;i&lt;&lt;&quot;]&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Standort: &quot;&lt;&lt;standOrt[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Anzahl Container: &quot;&lt;&lt;anzahlContainer[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Kapazitaet Container: &quot;&lt;&lt;kapazitaetContainer[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Preis je Container: &quot;&lt;&lt;preis_je_container[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Gesamtumsatz:.........&quot;&lt;&lt;gesamtUmsatz&lt;&lt;endl;<br />
cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;</p>
<p>}<br />
//------------------------------------------------------------------------------<br />
void containerSchiff::veraendere_containerSchiff()<br />
{<br />
int i;</p>
<p>cout&lt;&lt;&quot;Standort: &quot;;<br />
cin&gt;&gt;standOrt[i];<br />
cout&lt;&lt;&quot;Anzahl Container: &quot;;<br />
cin&gt;&gt;anzahlContainer[i];<br />
cout&lt;&lt;&quot;Kapazitaet Container: &quot;;<br />
cin&gt;&gt;kapazitaetContainer[i];<br />
cout&lt;&lt;&quot;Preis je Container: &quot;;<br />
cin&gt;&gt;preis_je_container[i];</p>
<p>}<br />
//------------------------------------------------------------------------------<br />
void containerSchiff::belade_containerSchiff()<br />
{<br />
int zuladung_container;<br />
int i;<br />
if (kapazitaetContainer&gt;anzahlContainer)<br />
{<br />
cout&lt;&lt;&quot;Wieviel Container sollen auf das Schiff geladen werden?&quot;;<br />
cin&gt;&gt;zuladung_container;</p>
<p>anzahlContainer[i]=anzahlContainer[i]+zuladung_container;<br />
}</p>
<p>}</p>
<p>//------------------------------------------------------------------------------<br />
void containerSchiff::entlade_containerSchiff()<br />
{</p>
<p>int abladung_container;<br />
float gesamtUmsatz=0;<br />
int i;</p>
<p>cout&lt;&lt;&quot;Wieviel Container sollen vom Schiff geladen werden?&quot;;<br />
cin&gt;&gt;abladung_container;</p>
<p>anzahlContainer[i]=anzahlContainer[i]-abladung_container;</p>
<p>gesamtUmsatz=gesamtUmsatz+(abladung_container*preis_je_container[i]);</p>
<p>}</p>
<p>//------------------------------------------------------------------------------<br />
void containerSchiff::fahre_containerSchiff()<br />
{<br />
if (anzahlContainer&lt;0)<br />
{<br />
cout&lt;&lt;&quot;Das Schiff ist fahrbereit.&quot;&lt;&lt;endl;<br />
}<br />
else<br />
{<br />
cout&lt;&lt;&quot;Das Schiff ist nicht fahrbereit.&quot;&lt;&lt;endl;<br />
}<br />
}<br />
//------------------------------------------------------------------------------<br />
int containerSchiff::gebeStandOrt()<br />
{<br />
cout&lt;&lt;&quot;Standort: &quot;&lt;&lt;standOrt&lt;&lt;endl;<br />
}<br />
//------------------------------------------------------------------------------</p>
<p>Mein Problem ist, dass, wenn ich eingebe, welches Schiff ich bearbeiten moechte, dass wenn ich da z.B. 1 eingebe immer das schiff 0 mir angezeigt wird.<br />
wie geht das, dass wenn ich schiff 1 eingebe auch von schiff 1 die daten dann angezeigt werden?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/161229/c</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 19:02:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/161229.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Oct 2006 16:26:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 16:26:19 GMT]]></title><description><![CDATA[<p>Ich hab in C++ ein Problem:<br />
Mein Programm:</p>
<p>#include &lt;iostream&gt;<br />
#include &lt;stdlib.h&gt;</p>
<p>using namespace std;<br />
class containerSchiff<br />
{<br />
private:<br />
int standOrt[3];<br />
int anzahlContainer[3];<br />
int kapazitaetContainer[3];<br />
int schiff[3];<br />
float preis_je_container[3];<br />
float gesamtUmsatz;</p>
<p>public:<br />
containerSchiff();<br />
~containerSchiff();<br />
void zeige_containerSchiff();<br />
void veraendere_containerSchiff();<br />
void belade_containerSchiff();<br />
void entlade_containerSchiff();<br />
void fahre_containerSchiff();<br />
int gebeStandOrt();<br />
};<br />
//------------------------------------------------------------------------------<br />
//Hauptprogramm<br />
int main(void)<br />
{<br />
containerSchiff container1;<br />
char wahl;<br />
int schiff[3];<br />
int standOrt[3];<br />
int anzahlContainer[3];<br />
int kapazitaetContainer[3];<br />
float preis_je_container[3];</p>
<p>int i;</p>
<p>cout&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Welches Schiff wollen sie bearbeiten?&quot;;<br />
cin&gt;&gt;i;<br />
cout&lt;&lt;endl;</p>
<p>while(wahl!='E')<br />
{<br />
cout&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Auswahl&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;========&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Containerschiff zeigen......1&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Containerschiff veraendern..2&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Containerschiff beladen.....3&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Containerschiff entladen....4&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Containerschiff fahren......5&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Standort geben..............6&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Ende........................E&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Wahl.......................:&quot;;<br />
cin&gt;&gt;wahl;</p>
<p>switch(wahl)<br />
{<br />
case '1': container1.zeige_containerSchiff();break;<br />
case '2': container1.veraendere_containerSchiff();break;<br />
case '3': container1.belade_containerSchiff();break;<br />
case '4': container1.entlade_containerSchiff();break;<br />
case '5': container1.fahre_containerSchiff();break;<br />
case '6': container1.gebeStandOrt();break;<br />
default: system(&quot;PAUSE&quot;);<br />
return 0;<br />
}</p>
<p>}</p>
<p>system(&quot;PAUSE&quot;);<br />
return 0;<br />
}//Ende Hauptprorgamm<br />
//------------------------------------------------------------------------------<br />
//Implementation der Elemente<br />
containerSchiff::containerSchiff()<br />
{<br />
int i;<br />
for(i=0;i&lt;3;i++)<br />
{<br />
cout&lt;&lt;&quot;Definieren Sie ihr Schiff&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Schiff[&quot;&lt;&lt;i&lt;&lt;&quot;]&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Standort: &quot;;<br />
cin&gt;&gt;standOrt[i];<br />
cout&lt;&lt;&quot;Anzahl Container: &quot;;<br />
cin&gt;&gt;anzahlContainer[i];<br />
cout&lt;&lt;&quot;Kapazitaet Container: &quot;;<br />
cin&gt;&gt;kapazitaetContainer[i];<br />
cout&lt;&lt;&quot;Preis je Container: &quot;;<br />
cin&gt;&gt;preis_je_container[i];<br />
}<br />
for(i=0;i&lt;3;i++)<br />
{<br />
cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Schiff:..............[&quot;&lt;&lt;i&lt;&lt;&quot;]&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Standort: &quot;&lt;&lt;standOrt[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Anzahl Container: &quot;&lt;&lt;anzahlContainer[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Kapazitaet Container: &quot;&lt;&lt;kapazitaetContainer[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Preis je Container: &quot;&lt;&lt;preis_je_container[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Gesamtumsatz:.........&quot;&lt;&lt;gesamtUmsatz&lt;&lt;endl;<br />
cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;</p>
<p>}<br />
}<br />
//------------------------------------------------------------------------------<br />
containerSchiff::~containerSchiff()<br />
{<br />
cout&lt;&lt;&quot;Destruktor&quot;&lt;&lt;endl;<br />
}<br />
//------------------------------------------------------------------------------<br />
void containerSchiff::zeige_containerSchiff()<br />
{<br />
float gesamtUmsatz=0;<br />
int i;</p>
<p>cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Schiff:..............[&quot;&lt;&lt;i&lt;&lt;&quot;]&quot;&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Standort: &quot;&lt;&lt;standOrt[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Anzahl Container: &quot;&lt;&lt;anzahlContainer[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Kapazitaet Container: &quot;&lt;&lt;kapazitaetContainer[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Preis je Container: &quot;&lt;&lt;preis_je_container[i]&lt;&lt;endl;<br />
cout&lt;&lt;&quot;Gesamtumsatz:.........&quot;&lt;&lt;gesamtUmsatz&lt;&lt;endl;<br />
cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;</p>
<p>}<br />
//------------------------------------------------------------------------------<br />
void containerSchiff::veraendere_containerSchiff()<br />
{<br />
int i;</p>
<p>cout&lt;&lt;&quot;Standort: &quot;;<br />
cin&gt;&gt;standOrt[i];<br />
cout&lt;&lt;&quot;Anzahl Container: &quot;;<br />
cin&gt;&gt;anzahlContainer[i];<br />
cout&lt;&lt;&quot;Kapazitaet Container: &quot;;<br />
cin&gt;&gt;kapazitaetContainer[i];<br />
cout&lt;&lt;&quot;Preis je Container: &quot;;<br />
cin&gt;&gt;preis_je_container[i];</p>
<p>}<br />
//------------------------------------------------------------------------------<br />
void containerSchiff::belade_containerSchiff()<br />
{<br />
int zuladung_container;<br />
int i;<br />
if (kapazitaetContainer&gt;anzahlContainer)<br />
{<br />
cout&lt;&lt;&quot;Wieviel Container sollen auf das Schiff geladen werden?&quot;;<br />
cin&gt;&gt;zuladung_container;</p>
<p>anzahlContainer[i]=anzahlContainer[i]+zuladung_container;<br />
}</p>
<p>}</p>
<p>//------------------------------------------------------------------------------<br />
void containerSchiff::entlade_containerSchiff()<br />
{</p>
<p>int abladung_container;<br />
float gesamtUmsatz=0;<br />
int i;</p>
<p>cout&lt;&lt;&quot;Wieviel Container sollen vom Schiff geladen werden?&quot;;<br />
cin&gt;&gt;abladung_container;</p>
<p>anzahlContainer[i]=anzahlContainer[i]-abladung_container;</p>
<p>gesamtUmsatz=gesamtUmsatz+(abladung_container*preis_je_container[i]);</p>
<p>}</p>
<p>//------------------------------------------------------------------------------<br />
void containerSchiff::fahre_containerSchiff()<br />
{<br />
if (anzahlContainer&lt;0)<br />
{<br />
cout&lt;&lt;&quot;Das Schiff ist fahrbereit.&quot;&lt;&lt;endl;<br />
}<br />
else<br />
{<br />
cout&lt;&lt;&quot;Das Schiff ist nicht fahrbereit.&quot;&lt;&lt;endl;<br />
}<br />
}<br />
//------------------------------------------------------------------------------<br />
int containerSchiff::gebeStandOrt()<br />
{<br />
cout&lt;&lt;&quot;Standort: &quot;&lt;&lt;standOrt&lt;&lt;endl;<br />
}<br />
//------------------------------------------------------------------------------</p>
<p>Mein Problem ist, dass, wenn ich eingebe, welches Schiff ich bearbeiten moechte, dass wenn ich da z.B. 1 eingebe immer das schiff 0 mir angezeigt wird.<br />
wie geht das, dass wenn ich schiff 1 eingebe auch von schiff 1 die daten dann angezeigt werden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149376</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149376</guid><dc:creator><![CDATA[Rinilein]]></dc:creator><pubDate>Wed, 04 Oct 2006 16:26:19 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 17:26:01 GMT]]></title><description><![CDATA[<p>Erstmal ein paar Sachen der Übersicht halber<br />
1. es ist nicht gut dem thread nur den titel c++ in einem c++ forum zu geben<br />
2. hast du zahlreiche formatierungsmglk beim erstellen...<br />
3. sollte man den code nicht linksbündig angeben, is echt **** zu lesen...</p>
<p>Desweiteren Rate ich auch mal an, hier ein paar faq zu studieren...<br />
Der Code sieht nicht sonderlich gut aus...<br />
Nun zum Problem:</p>
<p>Du liest zwar die variable i ein, jedoch verwendest du sie im weiteren Verlauf überhaupt nicht. Woher soll da also eine Verwendung dessen kommen ?<br />
Desweiteren erstellst du in der main() eine menge variablen, die du dort überhaupt nicht nutzt.<br />
Eine Klasse ist dazu gedacht als Schablone zu dienen, von der mehrere Objekte erstellt werden. Du erstellst nur ein einziges Objekt und ich glaube so hast du das mit der Bezeichung Container auch nicht gemeint... Statt der Klasse Container solltest du eine klasse Schiff machen und davon einen Array anlegen... übrigens sollten in einem Konstruktor keine abfragen stehen...<br />
Viel erfolg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149407</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149407</guid><dc:creator><![CDATA[l4guna]]></dc:creator><pubDate>Wed, 04 Oct 2006 17:26:01 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 18:01:39 GMT]]></title><description><![CDATA[<p>na vielen dank auch.<br />
1. hat unser lehrer gemeint, wir sollen die klasse so nennen, also das war nicht meine erfindung.<br />
2. hab ich 0 verstanden von dem was du eben geschrieben hast.<br />
3. koenntest du mir das nochmal genauer erklaeren?<br />
4. haben wir das so in der schule gelernt, das programm so zu strukturieren, war also auch nicht meine erfindung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149420</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149420</guid><dc:creator><![CDATA[Rinilein]]></dc:creator><pubDate>Wed, 04 Oct 2006 18:01:39 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 18:07:30 GMT]]></title><description><![CDATA[<p>Beim schreiben hier im Forum sollst du deinem Thema einen Besseren Titel geben. Und nicht einfach nur &quot;C++&quot;, da checken wir ja gar nicht worum's geht.</p>
<p>Außerdem benutz bitte die C++-Tags. Dann sieht alles schön aus. Guck:</p>
<p>ohne tags:<br />
int main()<br />
{<br />
std::cout &lt;&lt; &quot;asd&quot;;<br />
}</p>
<p>mit tags:</p>
<pre><code class="language-cpp">int main()
{
   std::cout &lt;&lt; &quot;asd&quot;;
}
</code></pre>
<p>Das geht so: [ cpp ] text [ /cpp ] nur ohne die leerzeichen<br />
Anschauen bitte: <a href="http://c-plusplus.net/forum/viewtopic-var-t-is-136013.html" rel="nofollow">http://c-plusplus.net/forum/viewtopic-var-t-is-136013.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149423</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149423</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Wed, 04 Oct 2006 18:07:30 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 18:13:30 GMT]]></title><description><![CDATA[<p>Zu l4gunas Punkt 2 hier mal eine Demonstration des [ cpp] Tags hier im Board, die Formatierungen kommen von AStyler (nicht dass jemand meint ich hätte mir hier viel Arbeit gemacht :D)</p>
<p>Im Quellcode findest Du ein paar Kommentare meinerseits. Wenn irgendwas davon nicht den Lehren Eures Lehrers entspricht tuts mir leid, wir machen hier nunmal ISO C++.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;stdlib.h&gt; // Heisst in C++ cstdlib, nicht stdlib.h

using namespace std;

class containerSchiff
{
private:
    int standOrt[3];
    int anzahlContainer[3];
    int kapazitaetContainer[3];
    int schiff[3];
    float preis_je_container[3];
    float gesamtUmsatz;

public:
    containerSchiff();
    ~containerSchiff();
    void zeige_containerSchiff(); // wieso soll jede Methode von containerSchiff noch das Suffix _containerSchiff haben? Das ist nicht der Sinn von Kapselung
    void veraendere_containerSchiff();
    void belade_containerSchiff();
    void entlade_containerSchiff();
    void fahre_containerSchiff();
    int gebeStandOrt(); // Ausnahmen bestätigen die Regel?!
};
//------------------------------------------------------------------------------
//Hauptprogramm
int main(void)
{
    containerSchiff container1;
    char wahl;
    int schiff[3];
    int standOrt[3];
    int anzahlContainer[3];
    int kapazitaetContainer[3];
    float preis_je_container[3];

    int i;

    cout&lt;&lt;endl;
    cout&lt;&lt;&quot;Welches Schiff wollen sie bearbeiten?&quot;;
    cin&gt;&gt;i; // Du liest in &quot;i&quot; ein, und verwendest den Inhalt von i nie wieder
    cout&lt;&lt;endl;

    while (wahl!='E') // In wahl wurde noch nichts eingelesen, hier steht etwas zufälliges drin
    {
        cout&lt;&lt;endl;
        cout&lt;&lt;&quot;Auswahl&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;========&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Containerschiff zeigen......1&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Containerschiff veraendern..2&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Containerschiff beladen.....3&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Containerschiff entladen....4&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Containerschiff fahren......5&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Standort geben..............6&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Ende........................E&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Wahl.......................:&quot;;
        cin&gt;&gt;wahl;

        switch (wahl)
        {
        case '1':
            container1.zeige_containerSchiff();
            break;
        case '2':
            container1.veraendere_containerSchiff();
            break;
        case '3':
            container1.belade_containerSchiff();
            break;
        case '4':
            container1.entlade_containerSchiff();
            break;
        case '5':
            container1.fahre_containerSchiff();
            break;
        case '6':
            container1.gebeStandOrt();
            break;
        default:
            system(&quot;PAUSE&quot;);
            return 0; // jede Eingabe ausser 1-6 soll das Programm beenden?
        }

    }

    system(&quot;PAUSE&quot;);
    return 0;
}//Ende Hauptprorgamm
//------------------------------------------------------------------------------
//Implementation der Elemente
containerSchiff::containerSchiff()
{
    int i;
    for (i=0;i&lt;3;i++)
    {
        cout&lt;&lt;&quot;Definieren Sie ihr Schiff&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Schiff[&quot;&lt;&lt;i&lt;&lt;&quot;]&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Standort: &quot;;
        cin&gt;&gt;standOrt[i];
        cout&lt;&lt;&quot;Anzahl Container: &quot;;
        cin&gt;&gt;anzahlContainer[i];
        cout&lt;&lt;&quot;Kapazitaet Container: &quot;;
        cin&gt;&gt;kapazitaetContainer[i];
        cout&lt;&lt;&quot;Preis je Container: &quot;;
        cin&gt;&gt;preis_je_container[i];
    }
    for (i=0;i&lt;3;i++)
    {
        cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Schiff:..............[&quot;&lt;&lt;i&lt;&lt;&quot;]&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Standort: &quot;&lt;&lt;standOrt[i]&lt;&lt;endl;
        cout&lt;&lt;&quot;Anzahl Container: &quot;&lt;&lt;anzahlContainer[i]&lt;&lt;endl;
        cout&lt;&lt;&quot;Kapazitaet Container: &quot;&lt;&lt;kapazitaetContainer[i]&lt;&lt;endl;
        cout&lt;&lt;&quot;Preis je Container: &quot;&lt;&lt;preis_je_container[i]&lt;&lt;endl;
        cout&lt;&lt;&quot;Gesamtumsatz:.........&quot;&lt;&lt;gesamtUmsatz&lt;&lt;endl;
        cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;

    }
}
//------------------------------------------------------------------------------
containerSchiff::~containerSchiff()
{
    cout&lt;&lt;&quot;Destruktor&quot;&lt;&lt;endl;
}
//------------------------------------------------------------------------------
void containerSchiff::zeige_containerSchiff()
{
    float gesamtUmsatz=0;
    int i; // vermutlich soll hier das i aus main verwendet werden - das hier ist aber ein anderes i

    cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Schiff:..............[&quot;&lt;&lt;i&lt;&lt;&quot;]&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Standort: &quot;&lt;&lt;standOrt[i]&lt;&lt;endl;
    cout&lt;&lt;&quot;Anzahl Container: &quot;&lt;&lt;anzahlContainer[i]&lt;&lt;endl;
    cout&lt;&lt;&quot;Kapazitaet Container: &quot;&lt;&lt;kapazitaetContainer[i]&lt;&lt;endl;
    cout&lt;&lt;&quot;Preis je Container: &quot;&lt;&lt;preis_je_container[i]&lt;&lt;endl;
    cout&lt;&lt;&quot;Gesamtumsatz:.........&quot;&lt;&lt;gesamtUmsatz&lt;&lt;endl;
    cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;

}
//------------------------------------------------------------------------------
void containerSchiff::veraendere_containerSchiff()
{
    int i; // siehe oben

    cout&lt;&lt;&quot;Standort: &quot;;
    cin&gt;&gt;standOrt[i];
    cout&lt;&lt;&quot;Anzahl Container: &quot;;
    cin&gt;&gt;anzahlContainer[i];
    cout&lt;&lt;&quot;Kapazitaet Container: &quot;;
    cin&gt;&gt;kapazitaetContainer[i];
    cout&lt;&lt;&quot;Preis je Container: &quot;;
    cin&gt;&gt;preis_je_container[i];

}
//------------------------------------------------------------------------------
void containerSchiff::belade_containerSchiff()
{
    int zuladung_container;
    int i; // siehe oben
    if (kapazitaetContainer&gt;anzahlContainer)
    {
        cout&lt;&lt;&quot;Wieviel Container sollen auf das Schiff geladen werden?&quot;;
        cin&gt;&gt;zuladung_container;

        anzahlContainer[i]=anzahlContainer[i]+zuladung_container;
    }

}

//------------------------------------------------------------------------------
void containerSchiff::entlade_containerSchiff()
{

    int abladung_container;
    float gesamtUmsatz=0;
    int i; // siehe oben

    cout&lt;&lt;&quot;Wieviel Container sollen vom Schiff geladen werden?&quot;;
    cin&gt;&gt;abladung_container;

    anzahlContainer[i]=anzahlContainer[i]-abladung_container;

    gesamtUmsatz=gesamtUmsatz+(abladung_container*preis_je_container[i]);

}

//------------------------------------------------------------------------------
void containerSchiff::fahre_containerSchiff()
{
    if (anzahlContainer&lt;0)
    {
        cout&lt;&lt;&quot;Das Schiff ist fahrbereit.&quot;&lt;&lt;endl;
    }
    else
    {
        cout&lt;&lt;&quot;Das Schiff ist nicht fahrbereit.&quot;&lt;&lt;endl;
    }
}
//------------------------------------------------------------------------------
int containerSchiff::gebeStandOrt()
{
    cout&lt;&lt;&quot;Standort: &quot;&lt;&lt;standOrt&lt;&lt;endl;
}
//------------------------------------------------------------------------------
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1149429</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149429</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Wed, 04 Oct 2006 18:13:30 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 18:25:33 GMT]]></title><description><![CDATA[<p>man koennte meinen ich haette meinen lehrer bestochen in die 12. klasse zu kommen, wenn ich das hier so sehe.<br />
ich kann c++, zwar nicht immer alles perfekt, aber wir haben es so gelernt.<br />
und mein problem ist immer noch nicht geloest!<br />
wenn ihr doch alle so geistreiche perfektionisten seid, dann erstellt das programm korrekt, statt irgendwas zu reden, von falscher strukturierung etc.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149441</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149441</guid><dc:creator><![CDATA[Rinilein]]></dc:creator><pubDate>Wed, 04 Oct 2006 18:25:33 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 19:22:53 GMT]]></title><description><![CDATA[<p>Rinilein schrieb:</p>
<blockquote>
<p>man koennte meinen ich haette meinen lehrer bestochen in die 12. klasse zu kommen, wenn ich das hier so sehe.<br />
ich kann c++, zwar nicht immer alles perfekt, aber wir haben es so gelernt.<br />
und mein problem ist immer noch nicht geloest!<br />
wenn ihr doch alle so geistreiche perfektionisten seid, dann erstellt das programm korrekt, statt irgendwas zu reden, von falscher strukturierung etc.</p>
</blockquote>
<p>wenn du mal genau guckst, ist der oben gepostete quellcode mit Zitaten versehen, die dich auf fehler aufmerksam machen sollen, und solltest du ein Fehlerhinweis nicht verstehen frage diesen explizit nach. Übrigens sollte wenn du dies getan hast dein Problem nicht mehr da sein.<br />
Alles in einer angemessenen Form zu posten ist auch wichtig, um den Quelltext zu verstehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149468</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149468</guid><dc:creator><![CDATA[Krux]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:22:53 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 19:21:24 GMT]]></title><description><![CDATA[<p>ich poste ihn so, wie wir das gelernt haben, meine guete.<br />
ICH VERSTEHE DEN FEHLER NICHT, WIE OFT DENN NOCH? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149470</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149470</guid><dc:creator><![CDATA[Rinilein]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:21:24 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 19:25:53 GMT]]></title><description><![CDATA[<p>Rinilein schrieb:</p>
<blockquote>
<p>ICH VERSTEHE DEN FEHLER NICHT, WIE OFT DENN NOCH? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
</blockquote>
<p>Welchen Fehler?</p>
<p>mfg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149474</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149474</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:25:53 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 19:35:56 GMT]]></title><description><![CDATA[<p>Rinilein schrieb:</p>
<blockquote>
<p>ich poste ihn so, wie wir das gelernt haben, meine guete.<br />
ICH VERSTEHE DEN FEHLER NICHT, WIE OFT DENN NOCH? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
</blockquote>
<p>Du erstellt immer wieder in deinen Funktionen ein neues i (mit dem wert 0) welches du dann benutzt um auf deine Daten zuzugreifen.</p>
<pre><code class="language-cpp">{
    float gesamtUmsatz=0;
    int i; // vermutlich soll hier das i aus main verwendet werden - das hier ist aber ein anderes i

    cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Schiff:..............[&quot;&lt;&lt;i&lt;&lt;&quot;]&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Standort: &quot;&lt;&lt;standOrt[i]&lt;&lt;endl;
    cout&lt;&lt;&quot;Anzahl Container: &quot;&lt;&lt;anzahlContainer[i]&lt;&lt;endl;
    cout&lt;&lt;&quot;Kapazitaet Container: &quot;&lt;&lt;kapazitaetContainer[i]&lt;&lt;endl;
    cout&lt;&lt;&quot;Preis je Container: &quot;&lt;&lt;preis_je_container[i]&lt;&lt;endl;
    cout&lt;&lt;&quot;Gesamtumsatz:.........&quot;&lt;&lt;gesamtUmsatz&lt;&lt;endl;
    cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;

}
</code></pre>
<p>Das Problem könnte behoben werden, wenn du das &quot;int i;&quot; aus deinen Funktionen entfernst, und einmal i als globale Variable angibst. Dies ist aber keine gute Lösung, besser wäre es i als Parameter deinen Funktionen zu übergeben</p>
<p>Edit:<br />
Es wäre hilfreich, wenn du dir das Kapitel in deinem c++ Buch über Gültigkeitsbereich und Lebensdauer von Variablen noch mal durchliest.</p>
<p>hier noch mal das wichtigste:</p>
<p>int i: eine Variable wird erzeugt und Speicher dafür reserviert (kann so viel ich weiß alle möglichen stertwerte haben ist zufällig, aber meist 0.</p>
<p>eine zwischen zwei {} geschweiften Klammern erschaffene Variabe existiert auch nur da, danach ist sie wieder gelöscht und auch in den Funktionen, die von da auf aufgerufen werden ist sie nicht verfügbar.</p>
<p>und jetzt versuch mal die Ausgabe des folgenden Programms zu erklären.</p>
<pre><code class="language-cpp">int main (void){
int i = 0;
{
int i = 1;

cout &lt;&lt; i &lt;&lt; endl;
}
cout &lt;&lt; i &lt;&lt; endl;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1149475</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149475</guid><dc:creator><![CDATA[Krux]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:35:56 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 19:30:16 GMT]]></title><description><![CDATA[<p>koenntest du mir viell. das ganze programm ohne die ganzen i's funktionsfaehig erstellen? waere wirklich nett, ich komm da gar nicht mehr klar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149478</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149478</guid><dc:creator><![CDATA[Rinilein]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:30:16 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 19:33:19 GMT]]></title><description><![CDATA[<p>Rinilein schrieb:</p>
<blockquote>
<p>ich kann c++, zwar nicht immer alles perfekt, aber wir haben es so gelernt.</p>
</blockquote>
<p>Das halte ich, mit Verlaub gesagt, für eine gewagte Behauptung angesichts der Tatsache dass Du mit der Gültigkeitsdauer von Variablen offenbar nichts anfangen kannst. Selbst nach mehreren expliziten Hinweisen nicht.</p>
<p>Ergänzend zu Krux' Post: Noch besser wäre es natürlich, in <strong>einem</strong> Objekt vom Typ &quot;containerSchiff&quot; nicht die Daten von offenbar <strong>drei</strong> Schiffen zu speichern. Erstelle ein Array von containerSchiff in main(), dann hast Du das Problem i übergeben zu müssen garnicht.</p>
<p>Wenn das morgen noch keiner gemacht hat und ich ne ruhige Minute habe könnt ich wohl mal eine korrigierte Version zusammenstellen. Im Moment ruft das Bett nach mir <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/1149480</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149480</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:33:19 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 19:40:15 GMT]]></title><description><![CDATA[<p>Rinilein schrieb:</p>
<blockquote>
<p>koenntest du mir viell. das ganze programm ohne die ganzen i's funktionsfaehig erstellen? waere wirklich nett, ich komm da gar nicht mehr klar.</p>
</blockquote>
<p>Quellcode schreiben musst du schon noch selbst, aber lass doch mal ne suche nach allen &quot;int i;&quot; laufen, und lösche sie, dann packst du int i; vor dein main, dann hast du zwar ne globale Variable (globale variablen sind böse genau wie goto), aber es müsste funktionieren</p>
<p>PS hast du mein letzten Edit des vorherigen Posts von mir gelesen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149486</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149486</guid><dc:creator><![CDATA[Krux]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:40:15 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 19:46:12 GMT]]></title><description><![CDATA[<p>ich versteh grad nur bahnhof, zudem bin ich grad total verzweifelt.<br />
ich versteh das mit den i's nicht, mensch.<br />
es ist schon spaet und das ist hausaufgabe bis morgen.. ich sitz da schon mind. 6 stunden dran.<br />
ich schreib naechste woche ne arbeit ueber dieses thema. hallejulia.</p>
<p>@der, der so tolle sprueche klopft</p>
<p>du hast wirtschaftsinformatik viell. studiert, also fuehr dich hier nciht wie den tollsten auf, denn der bist du nicht. <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="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149492</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149492</guid><dc:creator><![CDATA[Rinilein]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:46:12 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 19:49:53 GMT]]></title><description><![CDATA[<p>Rinilein schrieb:</p>
<blockquote>
<p>ich versteh grad nur bahnhof, zudem bin ich grad total verzweifelt.<br />
ich versteh das mit den i's nicht, mensch.<br />
es ist schon spaet und das ist hausaufgabe bis morgen.. ich sitz da schon mind. 6 stunden dran.<br />
ich schreib naechste woche ne arbeit ueber dieses thema. hallejulia.</p>
<p>@der, der so tolle sprueche klopft</p>
<p>du hast wirtschaftsinformatik viell. studiert, also fuehr dich hier nciht wie den tollsten auf, denn der bist du nicht. <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="🙄"
    /></p>
</blockquote>
<p>Ich hab ferien <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="😃"
    /><br />
aber hast glück, Info ist mein bestes fach zur zeit und ich bin von Natur aus hilfsbereit.</p>
<p>Ich bastel dann mal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149497</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149497</guid><dc:creator><![CDATA[Krux]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:49:53 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 19:52:02 GMT]]></title><description><![CDATA[<p>vielen dank <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="😉"
    /><br />
aber nicht mit dem int i; vor dem main, weil das hatten wir noch nicht, wir hatten diese uebergabeparameter bei klassen auch noch nicht.<br />
das muss doch auch irgendwie anders gehen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149499</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149499</guid><dc:creator><![CDATA[Rinilein]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:52:02 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 19:52:34 GMT]]></title><description><![CDATA[<p>Rinilein schrieb:</p>
<blockquote>
<p>ich sitz da schon mind. 6 stunden dran.</p>
</blockquote>
<p>Ich glaub eher du hast gerade angefangen und stehst nun unter Zeitdruck <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="😃"
    /><br />
Ich rate dir mal im Unttericht besser und konzentrierter aufzupassen. Denn ihr bekommt sicherlich nicht etwas auf, was ihr nicht hättet lösen können.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149501</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149501</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:52:34 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 20:14:03 GMT]]></title><description><![CDATA[<p>Krux? <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 />
wo bleibt die antwort <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/1149521</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149521</guid><dc:creator><![CDATA[Rinilein]]></dc:creator><pubDate>Wed, 04 Oct 2006 20:14:03 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 20:20:55 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;stdlib.h&gt; // Heisst in C++ cstdlib, nicht stdlib.h

using namespace std;

class containerSchiff
{
private:
    int standOrt;
    int anzahlContainer;
    int kapazitaetContainer;
    int schiff;
    float preis_je_container;
    float gesamtUmsatz;

public:
    containerSchiff();
    ~containerSchiff();
    void zeige();
    void veraendere();
    void belade();
    void entlade();
    void fahre();
    int gebeStandOrt();
};
//------------------------------------------------------------------------------
//Hauptprogramm
int main(void)
{
    containerSchiff container1[3];
    char wahl;
    /*          Wozu sollen diese Variablen gut sein?
    int schiff[3];
    int standOrt[3];
    int anzahlContainer[3];
    int kapazitaetContainer[3];
    float preis_je_container[3];
	*/

    int i;

    cout&lt;&lt;endl;
    cout&lt;&lt;&quot;Welches Schiff wollen sie bearbeiten?&quot;;
    cin&gt;&gt;i;
    cout&lt;&lt;endl;

    while (wahl!='E') // In wahl wurde noch nichts eingelesen, hier steht etwas zufälliges drin
    {
        cout&lt;&lt;endl;
        cout&lt;&lt;&quot;Auswahl&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;========&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Containerschiff zeigen......1&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Containerschiff veraendern..2&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Containerschiff beladen.....3&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Containerschiff entladen....4&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Containerschiff fahren......5&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Standort geben..............6&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Ende........................E&quot;&lt;&lt;endl;
        cout&lt;&lt;&quot;Wahl.......................:&quot;;
        cin&gt;&gt;wahl;

        switch (wahl)
        {
        case '1':
            container1[i].zeige();
            break;
        case '2':
            container1[i].veraendere();
            break;
        case '3':
            container1[i].belade();
            break;
        case '4':
            container1[i].entlade();
            break;
        case '5':
            container1[i].fahre();
            break;
        case '6':
            container1[i].gebeStandOrt();
            break;
        default:
            system(&quot;PAUSE&quot;);
            return 0; // jede Eingabe ausser 1-6 soll das Programm beenden?
        }

    }

    system(&quot;PAUSE&quot;);
    return 0;
}//Ende Hauptprorgamm
//------------------------------------------------------------------------------
//Implementation der Elemente
containerSchiff::containerSchiff(){

	cout&lt;&lt;&quot;Definieren Sie ihr Schiff&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Schiff&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Standort: &quot;;
    cin&gt;&gt;standOrt;
    cout&lt;&lt;&quot;Anzahl Container: &quot;;
    cin&gt;&gt;anzahlContainer;
    cout&lt;&lt;&quot;Kapazitaet Container: &quot;;
    cin&gt;&gt;kapazitaetContainer;
    cout&lt;&lt;&quot;Preis je Container: &quot;;
    cin&gt;&gt;preis_je_container;

    cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Schiff:.....Name waere nich schlecht nich wahr&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Standort:..............&quot;&lt;&lt;standOrt&lt;&lt;endl;
    cout&lt;&lt;&quot;Anzahl Container:......&quot;&lt;&lt;anzahlContainer&lt;&lt;endl;
    cout&lt;&lt;&quot;Kapazitaet Container:..&quot;&lt;&lt;kapazitaetContainer&lt;&lt;endl;
    cout&lt;&lt;&quot;Preis je Container:....&quot;&lt;&lt;preis_je_container&lt;&lt;endl;
    cout&lt;&lt;&quot;Gesamtumsatz:..........&quot;&lt;&lt;gesamtUmsatz&lt;&lt;endl;
    cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;

}
//------------------------------------------------------------------------------
containerSchiff::~containerSchiff()
{
    cout&lt;&lt;&quot;Destruktor&quot;&lt;&lt;endl;
}
//------------------------------------------------------------------------------
void containerSchiff::zeige()
{
    float gesamtUmsatz=0;

    cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Schiff:..............[]&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Standort: &quot;&lt;&lt;standOrt&lt;&lt;endl;
    cout&lt;&lt;&quot;Anzahl Container: &quot;&lt;&lt;anzahlContainer&lt;&lt;endl;
    cout&lt;&lt;&quot;Kapazitaet Container: &quot;&lt;&lt;kapazitaetContainer&lt;&lt;endl;
    cout&lt;&lt;&quot;Preis je Container: &quot;&lt;&lt;preis_je_container&lt;&lt;endl;
    cout&lt;&lt;&quot;Gesamtumsatz:.........&quot;&lt;&lt;gesamtUmsatz&lt;&lt;endl;
    cout&lt;&lt;&quot;--------------------------------------&quot;&lt;&lt;endl;

}
//------------------------------------------------------------------------------
void containerSchiff::veraendere()
{

    cout&lt;&lt;&quot;Standort: &quot;;
    cin&gt;&gt;standOrt;
    cout&lt;&lt;&quot;Anzahl Container: &quot;;
    cin&gt;&gt;anzahlContainer;
    cout&lt;&lt;&quot;Kapazitaet Container: &quot;;
    cin&gt;&gt;kapazitaetContainer;
    cout&lt;&lt;&quot;Preis je Container: &quot;;
    cin&gt;&gt;preis_je_container;

}
//------------------------------------------------------------------------------
void containerSchiff::belade()
{
    int zuladung_container;
    int i; // siehe oben
    if (kapazitaetContainer&gt;anzahlContainer)
    {
        cout&lt;&lt;&quot;Wieviel Container sollen auf das Schiff geladen werden?&quot;;
        cin&gt;&gt;zuladung_container;

        anzahlContainer += zuladung_container;
    }

}

//------------------------------------------------------------------------------
void containerSchiff::entlade()
{

    int abladung_container;

    cout&lt;&lt;&quot;Wieviel Container sollen vom Schiff geladen werden?&quot;;
    cin&gt;&gt;abladung_container;

    anzahlContainer -= abladung_container;

    gesamtUmsatz += abladung_container*preis_je_container;

}

//------------------------------------------------------------------------------
void containerSchiff::fahre()
{
    if (anzahlContainer&lt;0)  // nur wenn weniger als 1 container an bord ist ist das schiff Fahrbereit
    {
        cout&lt;&lt;&quot;Das Schiff ist fahrbereit.&quot;&lt;&lt;endl;
    }
    else
    {
        cout&lt;&lt;&quot;Das Schiff ist nicht fahrbereit.&quot;&lt;&lt;endl;
    }
}
//------------------------------------------------------------------------------
int containerSchiff::gebeStandOrt()
{
    cout&lt;&lt;&quot;Standort: &quot;&lt;&lt;standOrt&lt;&lt;endl;
    return standOrt;  //den Returnwert nicht vergessen, sonst kann man mit dem Wert im Programm nichts anfangen;
}
//------------------------------------------------------------------------------
</code></pre>
<p>Ich hab einiges verändert, und schau dir mal an, wo das i ist, nur noch im Haupstprogramm.</p>
<p>Du hattest eine klasse erstellt, die sich schiff gernannt hat, und dafon ein Objekt erstellt. Dieses objekt hatte den Inhalt von genau 3 Schiffen, was irgendwie ziemlich bescheuert ist.</p>
<p>Ich hab das so verändert, dass du 3 Objekte erstellst, die jeweils die Informationen von einem Schiff enthalten. Jetz ist das i in deinen Methoden auch völlig überflüssig geworden. Ich hoffe du verstehst jetzt auch mal wofür klassen da sind.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149522</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149522</guid><dc:creator><![CDATA[Krux]]></dc:creator><pubDate>Wed, 04 Oct 2006 20:20:55 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 20:29:35 GMT]]></title><description><![CDATA[<p>also 1. wieso return (standOrt)?<br />
wieso soll der an die hauptfunktion zurueckgegeben werden? in der hauptfunktion steht doch nirgends der standort?<br />
2. soll da ueberall das i sein. ich hab nen screenshot, wie das programm aussehen soll.<br />
wie kann ich das hier einfuegen?<br />
er zeigt bie mir auch bei dem &lt;1, was du meintest, was richtig waere fehlermeinung und die rueckgabe des standOrtes macht er auch als fehler.</p>
<p>der anfang des programmes ist:</p>
<p>definieren sie das schiff:<br />
schiff[0]<br />
alle eingaben<br />
.<br />
.<br />
.<br />
schiff[1]<br />
alle eingaben<br />
.<br />
.<br />
.<br />
schiff[2]</p>
<p>0 1 2 sind das i!!!!!!!!<br />
das sollen wir so machen<br />
danach kommt die aus ausgabe von [0] [1] [2] mit ihren eingaben, und danach kommt die fragen, welches schiff ich auswaehlen moechte, dann geb ich die 1 an, dann kommt das auswahlmenue, was ich mit dem ding machen will, dann geb ich 1 ein fuer daten anzeigen von schiff 1, was ich ja ausgewaehlt hab und dann zeigt er mir die daten von schiff [0] an.</p>
<p>das ist das problem!!!!<br />
und es muss das i da sein, das is die schiffsbezeichnung!!<br />
<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="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149531</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149531</guid><dc:creator><![CDATA[Rinilein]]></dc:creator><pubDate>Wed, 04 Oct 2006 20:29:35 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 20:52:28 GMT]]></title><description><![CDATA[<p>Rinilein schrieb:</p>
<blockquote>
<p>also 1. wieso return (standOrt)?<br />
wieso soll der an die hauptfunktion zurueckgegeben werden? in der hauptfunktion steht doch nirgends der standort?<br />
2. soll da ueberall das i sein. ich hab nen screenshot, wie das programm aussehen soll.<br />
wie kann ich das hier einfuegen?<br />
er zeigt bie mir auch bei dem &lt;1, was du meintest, was richtig waere fehlermeinung und die rueckgabe des standOrtes macht er auch als fehler.</p>
<p>der anfang des programmes ist:</p>
<p>definieren sie das schiff:<br />
schiff[0]<br />
alle eingaben<br />
.<br />
.<br />
.<br />
schiff[1]<br />
alle eingaben<br />
.<br />
.<br />
.<br />
schiff[2]</p>
<p>0 1 2 sind das i!!!!!!!!<br />
das sollen wir so machen<br />
danach kommt die aus ausgabe von [0] [1] [2] mit ihren eingaben, und danach kommt die fragen, welches schiff ich auswaehlen moechte, dann geb ich die 1 an, dann kommt das auswahlmenue, was ich mit dem ding machen will, dann geb ich 1 ein fuer daten anzeigen von schiff 1, was ich ja ausgewaehlt hab und dann zeigt er mir die daten von schiff [0] an.</p>
<p>das ist das problem!!!!<br />
und es muss das i da sein, das is die schiffsbezeichnung!!<br />
<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="😕"
    /></p>
</blockquote>
<p>return, nicht weils benutzt wird, sondern die Methode hat doch ein int davor, was bedeutet, dass auch einer zurückgegeben werden soll, ob du ihn benutzt oder nicht ist egal aber ohne ist doof, dann kanste auch gleich ne Void draus machen, aber das zurückzugeben ist fast noch wichtiger, als das zu schreiben. am besten wäre es, wenn du aus der Methode das cot ausbaust, und nur das return drin lässt, und statt dessen cout &lt;&lt; container1[i].gebeStandort() &lt;&lt; endl; ins main reinpackst, aber das ist jetzt nicht so wichtig.</p>
<p>um dein Problem zu lösen lösche einfach Zeile 112-121 und packe ein<br />
for (int j = 0; j &lt; 0; j++){<br />
cout &lt;&lt; &quot;schiff[&quot; &lt;&lt; i &lt;&lt; ']' &lt;&lt; endl;<br />
container1[j]zeige();<br />
}</p>
<p>zwischen zeile 30/31</p>
<p>Dann wäre ersmal die Reihenfolge wieder hergestellt.</p>
<p>Edit habs verändert, und den Rest schaffst selbst du. (Einfach danach kompilieren und testen. Danach gucken was passt.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149541</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149541</guid><dc:creator><![CDATA[Krux]]></dc:creator><pubDate>Wed, 04 Oct 2006 20:52:28 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 20:49:11 GMT]]></title><description><![CDATA[<p>naja, ich bekomm wohl keine antwort mehr.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149542</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149542</guid><dc:creator><![CDATA[Rinilein]]></dc:creator><pubDate>Wed, 04 Oct 2006 20:49:11 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 20:52:54 GMT]]></title><description><![CDATA[<p>ich hab langsam das gefuehl, dass mir hier keiner helfen will, sondern ihr mich fuer bloede haltet.<br />
diese erklaerungen bringen mich kein stueck weiter ans ziel.<br />
das sa schiff [0] statt schiff [1] steht hat keineswegs mit dem destruktor zutun, also werde ich den auch nicht loeschen.<br />
mir reichts jetzt. ich lass es so. ich hab mir wirklich mehr als genug gedanken darueber gemacht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149543</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149543</guid><dc:creator><![CDATA[Rinilein]]></dc:creator><pubDate>Wed, 04 Oct 2006 20:52:54 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 20:52:56 GMT]]></title><description><![CDATA[<p>Rinilein schrieb:</p>
<blockquote>
<p>naja, ich bekomm wohl keine antwort mehr.</p>
</blockquote>
<p>doch</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149544</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149544</guid><dc:creator><![CDATA[Krux]]></dc:creator><pubDate>Wed, 04 Oct 2006 20:52:56 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 21:00:57 GMT]]></title><description><![CDATA[<p>Rinilein schrieb:</p>
<blockquote>
<p>ich hab langsam das gefuehl, dass mir hier keiner helfen will, sondern ihr mich fuer bloede haltet.<br />
diese erklaerungen bringen mich kein stueck weiter ans ziel.<br />
das sa schiff [0] statt schiff [1] steht hat keineswegs mit dem destruktor zutun, also werde ich den auch nicht loeschen.<br />
mir reichts jetzt. ich lass es so. ich hab mir wirklich mehr als genug gedanken darueber gemacht.</p>
</blockquote>
<p>der index geht nunmal von 0-2 wenn du aber 1-3 da stehen haben willst, musst du einfach statt i i+1 ausgeben lassen. Und nein ich halte dich nicht für dumm, sondern hab mitlerweile mitbekommen das du ein Anfanger bist, der mit dem Problem nicht klar kommt, und unter Zeitdruck steht, sonst hätte ich die auch nicht so auffürlich dein Programm berichtigt. Und das mit dem Destruktor ha auch keiner behauptet, aber der Destruktor ist in deinem Programm überflssig, das heißt, dass du ihn besser gleich löschen solltest, aber da du ja bereits schon aufgehört hast, kann ich dir leider nicht weiterhelfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149546</guid><dc:creator><![CDATA[Krux]]></dc:creator><pubDate>Wed, 04 Oct 2006 21:00:57 GMT</pubDate></item><item><title><![CDATA[Reply to C++ on Wed, 04 Oct 2006 20:57:17 GMT]]></title><description><![CDATA[<p>Rinilein schrieb:</p>
<blockquote>
<p>ich hab langsam das gefuehl, dass mir hier keiner helfen will, sondern ihr mich fuer bloede haltet.</p>
</blockquote>
<p><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="🙄"
    /> <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="🙄"
    /> Oh mein Gott ...<br />
Hier sind Leute die sich mit deinem Problem beschftigen und dir versuchen zu helfen und du meinst immer noch es hilft dir keiner.</p>
<p>Ich habe langsam das Gefühl das du dir nicht helfen lassen willst. Hier kann dir auch keiner die ganze Sprache C++ beibringen. Gewisse Sachen solltest du schon wissen oder selbst mitbringen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149547</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149547</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 04 Oct 2006 20:57:17 GMT</pubDate></item></channel></rss>