<?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[Klassr zum ein-und ausgeben]]></title><description><![CDATA[<p>ich bin grad dabei mir meine eigene Klasse zu machen, aber ich komm nicht weiter.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

class ein_und_ausgabe
{
	fstream file;
	string dateiname;
	string ausgabe;

	ein_und_ausgabe();
	void schreiben(string i);
	void schließen();

};

ein_und_ausgabe::ein_und_ausgabe()
{
	dateiname = &quot;test&quot;;
	ausgabe = &quot;wer&quot;;
	file.open(dateiname, ios_base::out | ios_base::binary);
}

void ein_und_ausgabe::schreiben(string i)
{
	file &lt;&lt; i;
}

void ein_und_ausgabe::schließen()
{
	file.close();
}

int main()
{
	ein_und_ausgabe i;

	i.ausgabe = &quot;wer&quot;;
	i.schreiben();
	schließen(); // kann man das so machen??

	return 0;
}
</code></pre>
<p>leider funkioniert das in main alles nicht und visuall c++ sagt mir, dass auf alles bis auf schließen() nicht zugeriffen werden kann.<br />
was hab ich falsch gemacht??</p>
<p>danke schon mal im vorraus</p>
<p>gucky</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/275441/klassr-zum-ein-und-ausgeben</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 23:24:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/275441.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 14 Oct 2010 15:35:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Klassr zum ein-und ausgeben on Thu, 14 Oct 2010 15:35:14 GMT]]></title><description><![CDATA[<p>ich bin grad dabei mir meine eigene Klasse zu machen, aber ich komm nicht weiter.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

class ein_und_ausgabe
{
	fstream file;
	string dateiname;
	string ausgabe;

	ein_und_ausgabe();
	void schreiben(string i);
	void schließen();

};

ein_und_ausgabe::ein_und_ausgabe()
{
	dateiname = &quot;test&quot;;
	ausgabe = &quot;wer&quot;;
	file.open(dateiname, ios_base::out | ios_base::binary);
}

void ein_und_ausgabe::schreiben(string i)
{
	file &lt;&lt; i;
}

void ein_und_ausgabe::schließen()
{
	file.close();
}

int main()
{
	ein_und_ausgabe i;

	i.ausgabe = &quot;wer&quot;;
	i.schreiben();
	schließen(); // kann man das so machen??

	return 0;
}
</code></pre>
<p>leider funkioniert das in main alles nicht und visuall c++ sagt mir, dass auf alles bis auf schließen() nicht zugeriffen werden kann.<br />
was hab ich falsch gemacht??</p>
<p>danke schon mal im vorraus</p>
<p>gucky</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965654</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965654</guid><dc:creator><![CDATA[Gucky]]></dc:creator><pubDate>Thu, 14 Oct 2010 15:35:14 GMT</pubDate></item><item><title><![CDATA[Reply to Klassr zum ein-und ausgeben on Thu, 14 Oct 2010 15:38:14 GMT]]></title><description><![CDATA[<p>In der Klasse sind per Default alle Member privat. Also entweder class durch struct ersetzen oder die Funktionen public machen.</p>
<pre><code class="language-cpp">class ein_und_ausgabe
{
    fstream file;
    string dateiname;
    string ausgabe;
public:
    ein_und_ausgabe();
    void schreiben(string i);
    void schließen();
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1965656</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965656</guid><dc:creator><![CDATA[Vicious Falcon]]></dc:creator><pubDate>Thu, 14 Oct 2010 15:38:14 GMT</pubDate></item><item><title><![CDATA[Reply to Klassr zum ein-und ausgeben on Thu, 14 Oct 2010 15:42:28 GMT]]></title><description><![CDATA[<p>danke, das war der eine fehler, aber kann ich schließen() aufrufen??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965658</guid><dc:creator><![CDATA[Gucky]]></dc:creator><pubDate>Thu, 14 Oct 2010 15:42:28 GMT</pubDate></item><item><title><![CDATA[Reply to Klassr zum ein-und ausgeben on Thu, 14 Oct 2010 15:44:00 GMT]]></title><description><![CDATA[<p>Klar, i.schließen(); <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/1965660</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965660</guid><dc:creator><![CDATA[Vicious Falcon]]></dc:creator><pubDate>Thu, 14 Oct 2010 15:44:00 GMT</pubDate></item><item><title><![CDATA[Reply to Klassr zum ein-und ausgeben on Thu, 14 Oct 2010 15:48:52 GMT]]></title><description><![CDATA[<p>auch wenn ich i garnicht brauche bem schließen() ??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965661</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965661</guid><dc:creator><![CDATA[Gucky]]></dc:creator><pubDate>Thu, 14 Oct 2010 15:48:52 GMT</pubDate></item><item><title><![CDATA[Reply to Klassr zum ein-und ausgeben on Thu, 14 Oct 2010 15:53:44 GMT]]></title><description><![CDATA[<p>Gucky schrieb:</p>
<blockquote>
<p>auch wenn ich i garnicht brauche bem schließen() ??</p>
</blockquote>
<p>Doch, du brauchst.<br />
i.schließen() macht ja (i.file).close()</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965662</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965662</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 14 Oct 2010 15:53:44 GMT</pubDate></item><item><title><![CDATA[Reply to Klassr zum ein-und ausgeben on Thu, 14 Oct 2010 15:56:36 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">class ein_und_ausgabe
{
public:
  void schließen();
  // ...
};
</code></pre>
<p>Das ist doch eine Memberfunktion. schließen() geht nur, wenn du eine freie Funktion &quot;schließen&quot; definiert hast. Du meinst aber sicher i.schließen(). Generell solltest du dein Konzept aber noch einmal überdenken. Für so etwas gibt es Kon-und Destruktoren, file.close() brauchst du auch nicht direkt selber aufrufen.<br />
Und Buchstaben wie 'ß' oder Diakritika (ä,ö,ü etc.) würde ich im Code nicht schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965663</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965663</guid><dc:creator><![CDATA[Vicious Falcon]]></dc:creator><pubDate>Thu, 14 Oct 2010 15:56:36 GMT</pubDate></item><item><title><![CDATA[Reply to Klassr zum ein-und ausgeben on Thu, 14 Oct 2010 15:59:24 GMT]]></title><description><![CDATA[<p>ok</p>
<p>ein anderes problem ist, es wird nichts in die datei geschrieben.<br />
ich find leider nicht das problem, woran es liegt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965667</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965667</guid><dc:creator><![CDATA[Gucky]]></dc:creator><pubDate>Thu, 14 Oct 2010 15:59:24 GMT</pubDate></item><item><title><![CDATA[Reply to Klassr zum ein-und ausgeben on Thu, 14 Oct 2010 16:15:34 GMT]]></title><description><![CDATA[<p>problem hat sich erledigt</p>
<p>trotzdem noch einaml danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965675</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965675</guid><dc:creator><![CDATA[Gucky]]></dc:creator><pubDate>Thu, 14 Oct 2010 16:15:34 GMT</pubDate></item><item><title><![CDATA[Reply to Klassr zum ein-und ausgeben on Thu, 14 Oct 2010 17:04:44 GMT]]></title><description><![CDATA[<p>eine aller letzte frage noch:</p>
<p>wenn ich die klasse in eine headeerdatei packe, kann ich nicht mehr normal darauf zugreifen (z. B. ein_und_ausgabe i)<br />
jetzt meine frage, wie kann ich das machen??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965689</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965689</guid><dc:creator><![CDATA[Gucky]]></dc:creator><pubDate>Thu, 14 Oct 2010 17:04:44 GMT</pubDate></item><item><title><![CDATA[Reply to Klassr zum ein-und ausgeben on Fri, 15 Oct 2010 09:17:08 GMT]]></title><description><![CDATA[<p>Hast du die Headerdatei denn mittels</p>
<pre><code class="language-cpp">#include &quot;ein_und_ausgabe.h&quot; // oder wie auch immer deine Datei heißt
</code></pre>
<p>eingebunden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965987</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965987</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Fri, 15 Oct 2010 09:17:08 GMT</pubDate></item><item><title><![CDATA[Reply to Klassr zum ein-und ausgeben on Fri, 15 Oct 2010 15:00:05 GMT]]></title><description><![CDATA[<p>ja funktioniert auch alles</p>
<p>mein visual c++ hat etwas rumgesponnen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1966117</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1966117</guid><dc:creator><![CDATA[Gucky]]></dc:creator><pubDate>Fri, 15 Oct 2010 15:00:05 GMT</pubDate></item></channel></rss>