<?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[fstream in klassen]]></title><description><![CDATA[<p>Hallo Leute ich habe ein Problem mit dem Einbinden eines fstream objektes in eine klasse.<br />
Ich weiß nicht wieso, aber es funktioniert einfach nicht, wenn ich eine Datei lesen will, wo die lese und lade funktionen in einer klasse sind.</p>
<p>Wenn ich normal fstream.opebn.., fstream.write...fstream.close schreibe funktioniert alles, aber wenn ich eine klasse mit einer funktion erstelle und das dort mache geht es nicht.</p>
<p>Kann mir da einer helfen ??</p>
<pre><code>#include &lt;fstream&gt;
#include &lt;iostream&gt;

using namespace std;

class A
{
public:

	fstream f;
	A(string name) { Load(name); }
	~A() { }

	void Load(string a);

};
</code></pre>
<pre><code>#include &quot;a.h&quot;

void A::Load(string a)
{
	f.open(a.c_str(),fstream::binary);

	f.write(&quot;dsfsd&quot;,5);

	f.close();

}
</code></pre>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/312275/fstream-in-klassen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 02 Aug 2026 22:59:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/312275.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 30 Dec 2012 21:32:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to fstream in klassen on Sun, 30 Dec 2012 21:32:45 GMT]]></title><description><![CDATA[<p>Hallo Leute ich habe ein Problem mit dem Einbinden eines fstream objektes in eine klasse.<br />
Ich weiß nicht wieso, aber es funktioniert einfach nicht, wenn ich eine Datei lesen will, wo die lese und lade funktionen in einer klasse sind.</p>
<p>Wenn ich normal fstream.opebn.., fstream.write...fstream.close schreibe funktioniert alles, aber wenn ich eine klasse mit einer funktion erstelle und das dort mache geht es nicht.</p>
<p>Kann mir da einer helfen ??</p>
<pre><code>#include &lt;fstream&gt;
#include &lt;iostream&gt;

using namespace std;

class A
{
public:

	fstream f;
	A(string name) { Load(name); }
	~A() { }

	void Load(string a);

};
</code></pre>
<pre><code>#include &quot;a.h&quot;

void A::Load(string a)
{
	f.open(a.c_str(),fstream::binary);

	f.write(&quot;dsfsd&quot;,5);

	f.close();

}
</code></pre>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2284603</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2284603</guid><dc:creator><![CDATA[Bob Wolfskin]]></dc:creator><pubDate>Sun, 30 Dec 2012 21:32:45 GMT</pubDate></item><item><title><![CDATA[Reply to fstream in klassen on Sun, 30 Dec 2012 21:48:31 GMT]]></title><description><![CDATA[<p><strong>Es</strong> geht nicht. Das ist ja sehr aussagekräftig ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2284607</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2284607</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sun, 30 Dec 2012 21:48:31 GMT</pubDate></item><item><title><![CDATA[Reply to fstream in klassen on Sun, 30 Dec 2012 21:52:41 GMT]]></title><description><![CDATA[<p>Ja was soll ich sagen, ich bekomme immer ein fstream.bad-&gt;true, also wird die Datei nicht erstellt/geladen.</p>
<p>Wenn ich einfach folgendes im Main schreibe:</p>
<pre><code>fstream a(&quot;abc.txt&quot;,fstream::binary);
a.write(&quot;abc&quot;,3);
a.close();
</code></pre>
<p>Das geht einwandfrei.</p>
<p>Wenn ich das aber in den Konstruktor einer klasse packe:</p>
<pre><code>class A
{
public:
    A() { fstream a(&quot;abc.txt&quot;,fstream::binary);
a.write(&quot;abc&quot;,3);
a.close();
}

};

und mit A* a = new A(); das ganze erstelle bekomme ich ein fstream.bad-&gt;true
</code></pre>
<p>Ich weiß nicht warum</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2284609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2284609</guid><dc:creator><![CDATA[Bob Wolfskin]]></dc:creator><pubDate>Sun, 30 Dec 2012 21:52:41 GMT</pubDate></item><item><title><![CDATA[Reply to fstream in klassen on Sun, 30 Dec 2012 21:57:55 GMT]]></title><description><![CDATA[<p>Ja ich bin......dumm <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="🙂"
    /><br />
Mann muss ja noch fstream::out schreiben oder in fürs lesen, was ich vergessen habe <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/2284611</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2284611</guid><dc:creator><![CDATA[Bob Wolfskin]]></dc:creator><pubDate>Sun, 30 Dec 2012 21:57:55 GMT</pubDate></item><item><title><![CDATA[Reply to fstream in klassen on Sun, 30 Dec 2012 22:05:34 GMT]]></title><description><![CDATA[<p>Bob Wolfskin schrieb:</p>
<blockquote>
<pre><code class="language-cpp">using namespace std;
</code></pre>
</blockquote>
<p>Lass das in Headern bleiben!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2284614</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2284614</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Sun, 30 Dec 2012 22:05:34 GMT</pubDate></item><item><title><![CDATA[Reply to fstream in klassen on Sun, 30 Dec 2012 22:45:56 GMT]]></title><description><![CDATA[<p>fstreams als Member halte ich fuer ziemlich fragwuerdig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2284624</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2284624</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Sun, 30 Dec 2012 22:45:56 GMT</pubDate></item></channel></rss>