<?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 erbeten] Vektor einer Klasse --&amp;gt; PROBLEM GELÖST]]></title><description><![CDATA[<p>Zum Gruße,</p>
<p>im Zuge eines Programmierkurses sitze ich an einem Programm welches mich zu Verzweiflung treibt.</p>
<p>Ziel des Programmes soll folgendes sein:</p>
<p>Tankstellenprogramm<br />
___________________</p>
<p>Es soll ein Programm geschrieben werden welches nach einer Eingabe von n Tankstellen fragt. Um eine Tankstelle zu definieren gibt es 2 Werte:</p>
<p>string Adresse<br />
float Benzinpreis</p>
<p>die gemeinsam mit einer Eingabe() und Ausgabe() Funktion in einer Klasse Tankstelle definiert sind.</p>
<p>Hier der Code des Programmes:</p>
<p>tankstelle.h</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &lt;fstream&gt;
using namespace std;

class Tankstelle
{
	public:
	string Adresse;
	float Benzinpreis;

	void Eingabe();
	void Ausgabe();
};
</code></pre>
<p><a href="http://tankstelleflt.cc" rel="nofollow">tankstelleflt.cc</a> (die Eingabe/Ausgabe Funktionen)</p>
<pre><code>#include&lt;iostream&gt;
#include&lt;string&gt;
#include&lt;vector&gt;
#include&lt;fstream&gt;
#include &quot;tankstelle.h&quot;
using namespace std;

void Tankstelle::Eingabe()
{

	cout&lt;&lt;&quot;Geben Sie die Adresse ein: \n&quot;;
	cin&gt;&gt;Adresse;

	cout&lt;&lt;&quot;Geben Sie den Benzinpreis der Tankstelle &quot;&lt;&lt;Adresse&lt;&lt;&quot; ein:\n&quot;;
	cin&gt;&gt;Benzinpreis;

	cout&lt;&lt;endl;

}
void Tankstelle::Ausgabe()
{
	cout&lt;&lt;Adresse&lt;&lt;&quot; hat Preis: &quot;&lt;&lt;Benzinpreis&lt;&lt;endl;
}
</code></pre>
<p>und das Hauptprogramm</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &lt;fstream&gt;
#include &quot;tankstelle.h&quot;
using namespace std;

int main()
{
	int anzahl;
	vector&lt;Tankstelle&gt; tankstellen;

	cout&lt;&lt;&quot;Wieviele Eingaben wollen Sie taetigen?\n&quot;;
	cin&gt;&gt;anzahl;
	tankstellen.resize(anzahl);

	for(int i=1;i&lt;anzahl+1;i++)
	{
		tankstellen.Adresse[i]; //???
	}

	for(int j=1;j&lt;anzahl+1;j++)
	{

		tankstellen.Adresse[j](); //???
	}
	return 0;
}
</code></pre>
<p>In diesem Hauptprogramm liegt mein Problem an dem ich ettlicheStunden zehre.<br />
Wir sollten die Klasse Tankstelle durch einen Vektor definieren. Nur weiss ich leider nicht wie ich nun weiter vorgehen soll um die Zielstellung zu erfüllen.</p>
<p>Könnte mir einer helfen das Programm lauffähig zu machen? Ich verzweifele langsam und mir gehen die Ideen aus.</p>
<p>LG<br />
Matar</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/214515/hilfe-erbeten-vektor-einer-klasse-gt-problem-gelöst</link><generator>RSS for Node</generator><lastBuildDate>Tue, 13 Oct 2026 14:39:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/214515.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 May 2008 10:26:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Hilfe erbeten] Vektor einer Klasse --&amp;gt; PROBLEM GELÖST on Fri, 30 May 2008 10:42:28 GMT]]></title><description><![CDATA[<p>Zum Gruße,</p>
<p>im Zuge eines Programmierkurses sitze ich an einem Programm welches mich zu Verzweiflung treibt.</p>
<p>Ziel des Programmes soll folgendes sein:</p>
<p>Tankstellenprogramm<br />
___________________</p>
<p>Es soll ein Programm geschrieben werden welches nach einer Eingabe von n Tankstellen fragt. Um eine Tankstelle zu definieren gibt es 2 Werte:</p>
<p>string Adresse<br />
float Benzinpreis</p>
<p>die gemeinsam mit einer Eingabe() und Ausgabe() Funktion in einer Klasse Tankstelle definiert sind.</p>
<p>Hier der Code des Programmes:</p>
<p>tankstelle.h</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &lt;fstream&gt;
using namespace std;

class Tankstelle
{
	public:
	string Adresse;
	float Benzinpreis;

	void Eingabe();
	void Ausgabe();
};
</code></pre>
<p><a href="http://tankstelleflt.cc" rel="nofollow">tankstelleflt.cc</a> (die Eingabe/Ausgabe Funktionen)</p>
<pre><code>#include&lt;iostream&gt;
#include&lt;string&gt;
#include&lt;vector&gt;
#include&lt;fstream&gt;
#include &quot;tankstelle.h&quot;
using namespace std;

void Tankstelle::Eingabe()
{

	cout&lt;&lt;&quot;Geben Sie die Adresse ein: \n&quot;;
	cin&gt;&gt;Adresse;

	cout&lt;&lt;&quot;Geben Sie den Benzinpreis der Tankstelle &quot;&lt;&lt;Adresse&lt;&lt;&quot; ein:\n&quot;;
	cin&gt;&gt;Benzinpreis;

	cout&lt;&lt;endl;

}
void Tankstelle::Ausgabe()
{
	cout&lt;&lt;Adresse&lt;&lt;&quot; hat Preis: &quot;&lt;&lt;Benzinpreis&lt;&lt;endl;
}
</code></pre>
<p>und das Hauptprogramm</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &lt;fstream&gt;
#include &quot;tankstelle.h&quot;
using namespace std;

int main()
{
	int anzahl;
	vector&lt;Tankstelle&gt; tankstellen;

	cout&lt;&lt;&quot;Wieviele Eingaben wollen Sie taetigen?\n&quot;;
	cin&gt;&gt;anzahl;
	tankstellen.resize(anzahl);

	for(int i=1;i&lt;anzahl+1;i++)
	{
		tankstellen.Adresse[i]; //???
	}

	for(int j=1;j&lt;anzahl+1;j++)
	{

		tankstellen.Adresse[j](); //???
	}
	return 0;
}
</code></pre>
<p>In diesem Hauptprogramm liegt mein Problem an dem ich ettlicheStunden zehre.<br />
Wir sollten die Klasse Tankstelle durch einen Vektor definieren. Nur weiss ich leider nicht wie ich nun weiter vorgehen soll um die Zielstellung zu erfüllen.</p>
<p>Könnte mir einer helfen das Programm lauffähig zu machen? Ich verzweifele langsam und mir gehen die Ideen aus.</p>
<p>LG<br />
Matar</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1519577</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1519577</guid><dc:creator><![CDATA[Matar]]></dc:creator><pubDate>Fri, 30 May 2008 10:42:28 GMT</pubDate></item><item><title><![CDATA[Reply to [Hilfe erbeten] Vektor einer Klasse --&amp;gt; PROBLEM GELÖST on Fri, 30 May 2008 10:32:55 GMT]]></title><description><![CDATA[<p>So z.B.:</p>
<pre><code class="language-cpp">for(int i=0; i &lt; tankstellen.size(); ++i)
{
    tankstellen[i].Eingabe();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1519582</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1519582</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Fri, 30 May 2008 10:32:55 GMT</pubDate></item><item><title><![CDATA[Reply to [Hilfe erbeten] Vektor einer Klasse --&amp;gt; PROBLEM GELÖST on Fri, 30 May 2008 10:40:24 GMT]]></title><description><![CDATA[<p>Danke für die schnelle Antwort, ich teste es fix <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>EDIT:</p>
<p>Ich fass es nicht! Es klappt, Heureka.<br />
Ich habe unzählige Varianten probiert .. u.a. auch</p>
<pre><code>tankstelle.Eingabe()
</code></pre>
<p>hab nur immer [i] vergessen. Ich kann dir nicht genug danken!</p>
<p>LG<br />
Matar</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1519584</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1519584</guid><dc:creator><![CDATA[Matar]]></dc:creator><pubDate>Fri, 30 May 2008 10:40:24 GMT</pubDate></item><item><title><![CDATA[Reply to [Hilfe erbeten] Vektor einer Klasse --&amp;gt; PROBLEM GELÖST on Fri, 30 May 2008 10:35:00 GMT]]></title><description><![CDATA[<p>oder so</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &lt;fstream&gt;
using namespace std;

class Tankstelle
{
    public:
    string Adresse;
    float Benzinpreis;

    void Eingabe();
    void Ausgabe();
};

void Tankstelle::Eingabe()
{

    cout&lt;&lt;&quot;Geben Sie die Adresse ein: \n&quot;;
    cin&gt;&gt;Adresse;

    cout&lt;&lt;&quot;Geben Sie den Benzinpreis der Tankstelle &quot;&lt;&lt;Adresse&lt;&lt;&quot; ein:\n&quot;;
    cin&gt;&gt;Benzinpreis;

    cout&lt;&lt;endl;

}
void Tankstelle::Ausgabe()
{
    cout&lt;&lt;Adresse&lt;&lt;&quot; hat Preis: &quot;&lt;&lt;Benzinpreis&lt;&lt;endl;
}

int main()
{
    int anzahl;
    vector&lt;Tankstelle&gt; tankstellen;

    cout&lt;&lt;&quot;Wieviele Eingaben wollen Sie taetigen?\n&quot;;
    cin&gt;&gt;anzahl;
    tankstellen.resize(anzahl);

    for(int i=0;i&lt;anzahl;i++)
    {
        tankstellen[i].Adresse = &quot;daheim&quot;; //???
    }
    for(int i=0;i&lt;anzahl;i++)
    {
        cout&lt;&lt;tankstellen[i].Adresse&lt;&lt;endl; //???
    }

    return 0;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1519585</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1519585</guid><dc:creator><![CDATA[Firefighter]]></dc:creator><pubDate>Fri, 30 May 2008 10:35:00 GMT</pubDate></item><item><title><![CDATA[Reply to [Hilfe erbeten] Vektor einer Klasse --&amp;gt; PROBLEM GELÖST on Fri, 30 May 2008 10:41:42 GMT]]></title><description><![CDATA[<p>Auch dir Firefighter gilt meiin herzlichster Dank!</p>
<p>LG<br />
Matar</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1519590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1519590</guid><dc:creator><![CDATA[Matar]]></dc:creator><pubDate>Fri, 30 May 2008 10:41:42 GMT</pubDate></item></channel></rss>