<?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[Fehler c2248]]></title><description><![CDATA[<p>Guten Abend, da ich fast am verzweifeln bin, wende ich mich jetzt mal an dieses Forum. Und zwar geht es um das Einlesen eines einzelnen Strings und das Auslesen der gesamten eingelesenen Strings aus einer Datei.</p>
<p>Mach ich das hier richtig?</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

class Errorfail
{
	string buffer;
	public:
		ofstream dat_schr;
		ifstream dat_ausl;
		Errorfail(int _s)
		{
			int s = _s;
			dat_schr.open(&quot;Biberror.txt&quot;, ios::out);
			dat_schr &lt;&lt; &quot;Fehler bei Signatur &quot; &lt;&lt; s &lt;&lt; endl;
			dat_schr.close();
		}
		string message()
		{
			dat_ausl.open(&quot;Biberror.txt&quot;, ios::in);
			getline(dat_ausl,buffer);
			dat_ausl.close();
			return buffer;
		}
};
</code></pre>
<p>Bei mir kommt beim Compilieren <strong>folgende Fehlermeldung</strong>:<br />
*******************************************************************************</p>
<blockquote>
<p>------ Erstellen gestartet: Projekt: ueb4, Konfiguration: Debug Win32 ------<br />
1&gt;Kompilieren...<br />
1&gt;medien.cpp<br />
1&gt;c:\programme\microsoft visual studio 8\vc\include\fstream(802) : error C2248: &quot;std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios&quot;: Kein Zugriff auf private Member, dessen Deklaration in der std::basic_ios&lt;_Elem,_Traits&gt;-Klasse erfolgte.<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt; c:\programme\microsoft visual studio 8\vc\include\ios(151): Siehe Deklaration von 'std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt; Diese Diagnose trat in der vom Compiler generierten Funktion &quot;std::basic_ofstream&lt;_Elem,_Traits&gt;::basic_ofstream(const std::basic_ofstream&lt;_Elem,_Traits&gt; &amp;)&quot; auf.<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt;c:\programme\microsoft visual studio 8\vc\include*<em>fstream(675)</em>* : error C2248: &quot;std::basic_ios&lt;_Elem,_Traits&gt;::<strong>basic_ios</strong>&quot;: Kein Zugriff auf private Member, dessen Deklaration in der std::basic_ios&lt;_Elem,_Traits&gt;-Klasse erfolgte.<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt; c:\programme\microsoft visual studio 8\vc\include\ios(151): Siehe Deklaration von 'std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt; Diese Diagnose trat in der vom Compiler generierten Funktion &quot;std::basic_ifstream&lt;_Elem,_Traits&gt;::<strong>basic_ifstream</strong>(const std::<strong>basic_ifstream</strong>&lt;_Elem,_Traits&gt; &amp;)&quot; auf.<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt;Code wird generiert...<br />
1&gt;Kompilieren...<br />
1&gt;main.cpp<br />
1&gt;Code wird generiert...<br />
1&gt;Kompilieren...<br />
1&gt;container.cpp<br />
1&gt;Code wird generiert...<br />
1&gt;Das Buildprotokoll wurde unter &quot;file://c:\Dokumente und Einstellungen\Florian Bertsch\Desktop\ueb4\ueb4\Debug\BuildLog.htm&quot; gespeichert.<br />
1&gt;ueb4 - 2 Fehler, 0 Warnung(en)<br />
*******************************************************************************</p>
</blockquote>
<p>Aufgrund der fettmarkierten Teile in dieser Fehlermeldung muss es sich ja um einen Fehler bei der Datei bzw. Ausgabe handeln oder?</p>
<p><strong>Wäre für Hilfe wirklich sehr dankbar. Vielen Dank im Voraus!!!</strong></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/184504/fehler-c2248</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 17:37:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/184504.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 15 Jun 2007 20:37:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler c2248 on Fri, 15 Jun 2007 20:37:52 GMT]]></title><description><![CDATA[<p>Guten Abend, da ich fast am verzweifeln bin, wende ich mich jetzt mal an dieses Forum. Und zwar geht es um das Einlesen eines einzelnen Strings und das Auslesen der gesamten eingelesenen Strings aus einer Datei.</p>
<p>Mach ich das hier richtig?</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

class Errorfail
{
	string buffer;
	public:
		ofstream dat_schr;
		ifstream dat_ausl;
		Errorfail(int _s)
		{
			int s = _s;
			dat_schr.open(&quot;Biberror.txt&quot;, ios::out);
			dat_schr &lt;&lt; &quot;Fehler bei Signatur &quot; &lt;&lt; s &lt;&lt; endl;
			dat_schr.close();
		}
		string message()
		{
			dat_ausl.open(&quot;Biberror.txt&quot;, ios::in);
			getline(dat_ausl,buffer);
			dat_ausl.close();
			return buffer;
		}
};
</code></pre>
<p>Bei mir kommt beim Compilieren <strong>folgende Fehlermeldung</strong>:<br />
*******************************************************************************</p>
<blockquote>
<p>------ Erstellen gestartet: Projekt: ueb4, Konfiguration: Debug Win32 ------<br />
1&gt;Kompilieren...<br />
1&gt;medien.cpp<br />
1&gt;c:\programme\microsoft visual studio 8\vc\include\fstream(802) : error C2248: &quot;std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios&quot;: Kein Zugriff auf private Member, dessen Deklaration in der std::basic_ios&lt;_Elem,_Traits&gt;-Klasse erfolgte.<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt; c:\programme\microsoft visual studio 8\vc\include\ios(151): Siehe Deklaration von 'std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt; Diese Diagnose trat in der vom Compiler generierten Funktion &quot;std::basic_ofstream&lt;_Elem,_Traits&gt;::basic_ofstream(const std::basic_ofstream&lt;_Elem,_Traits&gt; &amp;)&quot; auf.<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt;c:\programme\microsoft visual studio 8\vc\include*<em>fstream(675)</em>* : error C2248: &quot;std::basic_ios&lt;_Elem,_Traits&gt;::<strong>basic_ios</strong>&quot;: Kein Zugriff auf private Member, dessen Deklaration in der std::basic_ios&lt;_Elem,_Traits&gt;-Klasse erfolgte.<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt; c:\programme\microsoft visual studio 8\vc\include\ios(151): Siehe Deklaration von 'std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt; Diese Diagnose trat in der vom Compiler generierten Funktion &quot;std::basic_ifstream&lt;_Elem,_Traits&gt;::<strong>basic_ifstream</strong>(const std::<strong>basic_ifstream</strong>&lt;_Elem,_Traits&gt; &amp;)&quot; auf.<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt;Code wird generiert...<br />
1&gt;Kompilieren...<br />
1&gt;main.cpp<br />
1&gt;Code wird generiert...<br />
1&gt;Kompilieren...<br />
1&gt;container.cpp<br />
1&gt;Code wird generiert...<br />
1&gt;Das Buildprotokoll wurde unter &quot;file://c:\Dokumente und Einstellungen\Florian Bertsch\Desktop\ueb4\ueb4\Debug\BuildLog.htm&quot; gespeichert.<br />
1&gt;ueb4 - 2 Fehler, 0 Warnung(en)<br />
*******************************************************************************</p>
</blockquote>
<p>Aufgrund der fettmarkierten Teile in dieser Fehlermeldung muss es sich ja um einen Fehler bei der Datei bzw. Ausgabe handeln oder?</p>
<p><strong>Wäre für Hilfe wirklich sehr dankbar. Vielen Dank im Voraus!!!</strong></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1306921</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1306921</guid><dc:creator><![CDATA[bodensee14]]></dc:creator><pubDate>Fri, 15 Jun 2007 20:37:52 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler c2248 on Fri, 15 Jun 2007 20:59:05 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

class Errorfail
{
	string buffer;
	public:
		ofstream dat_schr;
		ifstream dat_ausl;
		Errorfail(int _s)
		{
			int s = _s;
			dat_schr.open(&quot;Biberror.txt&quot;, ios::out);
			dat_schr &lt;&lt; &quot;Fehler bei Signatur &quot; &lt;&lt; s &lt;&lt; endl;
			dat_schr.close();
		}
		string message()
		{
			dat_ausl.open(&quot;Biberror.txt&quot;, ios::in);
			getline(dat_ausl,buffer);
			dat_ausl.close();
			return buffer;
		}
};

int main(){}
</code></pre>
<p>kompiliert bei mir problemlos. Ich denke mal du müsstest etwas mehr code posten</p>
<p>g++ 4.1.2-0ubuntu4</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1306933</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1306933</guid><dc:creator><![CDATA[darthdespotism]]></dc:creator><pubDate>Fri, 15 Jun 2007 20:59:05 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler c2248 on Fri, 15 Jun 2007 21:10:32 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#if !defined(ERROR_TO_FILE_H__INCLUDED)
#define ERROR_TO_FILE_H__INCLUDED

#include &lt;fstream&gt;
#include &lt;string&gt;

template&lt;typename T&gt;
class error_to_file
{
public:
    error_to_file(const T&amp; data) : m_data(data), m_stream(&quot;error.log&quot;, std::ios::out | std::ios::app)
    {
        std::ostringstream ss;
        ss &lt;&lt; &quot;FEHLER: &quot; &lt;&lt; m_data &lt;&lt; std::endl;
        m_dataString = ss.str();
        m_stream &lt;&lt; m_dataString &lt;&lt; std::endl;
    }
    const std::string&amp; message() const { return m_dataString; }

private:
    T m_data;
    std::ofstream m_stream;
    std::string m_dataString;
};

#endif // ERROR_TO_FILE_H__INCLUDED
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1306937</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1306937</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Fri, 15 Jun 2007 21:10:32 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler c2248 on Fri, 15 Jun 2007 21:52:02 GMT]]></title><description><![CDATA[<p><strong>main.cpp</strong></p>
<pre><code class="language-cpp">#include &quot;Medium.h&quot;
#include &quot;container.h&quot;
#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &lt;iomanip&gt;
using namespace std;

// Globale Variablen

	Container c;
	Video* video;
         Buch* buch;
	/*Medium* medium;*/

// Prototypen:

	void neues_Medium();
	void neues_Buch();
	void neues_Video();
	void show_Medien();
	void entleihe_Medien();
	void ruecknahme_Medien();

int main() 
{
	char auswahl = 'a';

	while (auswahl != 'q')
	{
		cout &lt;&lt; &quot;\n&quot;
			 /*&lt;&lt; &quot;(m) Neues Medium anlegen\n&quot;*/
			 &lt;&lt; &quot;(l) Medien anzeigen\n&quot;
			 &lt;&lt; &quot;(b) Neues Buch anlegen\n&quot;
			 &lt;&lt; &quot;(v) Neues Video anlegen\n&quot;
			 &lt;&lt; &quot;(e Signatur) Entleihen eines Mediums\n&quot;
			 &lt;&lt; &quot;(r Signatur) Ruecknahme eines Mediums\n&quot;
			 &lt;&lt; &quot;(q) Programm beenden\n\n&quot;;
		cout &lt;&lt; &quot;Auswahl: &quot;;
		cin.clear(); // Eingabepuffer leeren
		cin.sync();
		cin &gt;&gt; auswahl;
		cout &lt;&lt; endl;

		switch (auswahl) 
		{
			/*case 'm':
			case 'M': neues_Medium(); 
					break;*/
			case 'b':
			case 'B': neues_Buch();
					break;
			case 'v':
			case 'V': neues_Video();
					break;
			case 'l':
			case 'L': show_Medien(); 
					break;
			case 'e':
			case 'E': entleihe_Medien(); 
					break;
			case 'r':
			case 'R': ruecknahme_Medien(); 
					break;
			default: cout &lt;&lt; &quot;Bitte geben Sie einen gueltigen Befehl ein&quot; &lt;&lt; endl;
		}
	}
	return 0;
}

/*void neues_Medium()
{
	bool s;

	medium = new Medium();
	medium-&gt;init_Medium();
	s = c.add(medium);

	if(s == false)
	{
		cout &lt;&lt; &quot;Element konnte nicht hinzugefügt werden&quot;;
	}
	else
	{
		cout &lt;&lt; endl &lt;&lt;&quot;Element gespeichert&quot; &lt;&lt; endl;
	}
}*/

void neues_Buch()
{
	bool s;

	buch = new Buch();
    buch-&gt;init_Buch();//Aufruf der Initialisierungsfunktion Buch::init_Buch();
    s = c.add(buch);

	if(s == false)
	{
		cout &lt;&lt; &quot;Element konnte nicht hinzugefügt werden&quot;;
	}
	else
	{
		cout &lt;&lt; endl &lt;&lt;&quot;Element gespeichert&quot; &lt;&lt; endl;
	}
}

void neues_Video()
{
	bool s;

	video = new Video();
    video-&gt;init_Video();
	s = c.add(video);

	if(s == false)
	{
		cout &lt;&lt; &quot;Element konnte nicht hinzugefügt werden&quot;;
	}
	else
	{
		cout &lt;&lt; endl &lt;&lt;&quot;Element gespeichert&quot; &lt;&lt; endl;
	}
}

void show_Medien()
{	
	Medium::printUeberschrift(); //Ausgabe der Überschrift der Tabelle

	c.begin();

	if (c.endOfList()== false)
	{
		for (c.begin(); c.endOfList() == false; c.next())
		{
			c.getItem()-&gt;show_Medium();
		}
	}
	else 
	{
		cout &lt;&lt;&quot;-- Bibiothek leer --&quot;&lt;&lt;endl;
	}
}

void entleihe_Medien()
{
	int signatur;
	bool s = false;
	cout &lt;&lt; &quot;Bitte Signatur des Mediums eingeben, welche Sie entleihen moechten&quot; &lt;&lt; endl &lt;&lt; endl;
	cin &gt;&gt; signatur;
	cout &lt;&lt; endl;

	for (c.begin(); c.endOfList() == false; c.next())
	{
		if (c.getItem()-&gt;get_signatur() == signatur)
		{
			c.getItem()-&gt;entleihe_Medium();
			s = true;
		}
	}
	if (s == false)
	{
		cout &lt;&lt; &quot;Bitte geben Sie eine gueltige Signatur ein&quot; &lt;&lt; endl;
	}
}

void ruecknahme_Medien()
{
	int signatur;
	bool s = false;
	cout &lt;&lt; &quot;Bitte Signatur des Mediums eingeben, welche Sie zuruecknehmen moechten&quot; &lt;&lt; endl &lt;&lt; endl;
	cin &gt;&gt; signatur;
	cout &lt;&lt; endl;

	for (c.begin(); c.endOfList() == false; c.next())
	{
		if (c.getItem()-&gt;get_signatur() == signatur)
		{
			c.getItem()-&gt;ruecknahme_Medium();
			s = true;
		}
	}
	if (s == false)
	{
		cout &lt;&lt; &quot;Bitte geben Sie eine gueltige Signatur ein&quot; &lt;&lt; endl;
	}
}
</code></pre>
<p><strong>medien.cpp</strong></p>
<pre><code class="language-cpp">#include &quot;Medium.h&quot;
#include &lt;iostream&gt;
#include &lt;iomanip&gt; //nötig für setw()
#include &lt;string&gt;
using namespace std;

//Methoden der Klasse Medium

Medium::Medium()
{
     signatur=0;
}

void Medium::init_Medium()
{
	LeihStatus = praesent;
	cout &lt;&lt; &quot;Bitte Mediendaten eingeben: Signatur und Titel mit maximal 12 Zeichen\n\n&quot;;
	cout &lt;&lt; &quot;Signatur: &quot;;
	cin &gt;&gt; signatur;

	if(cin.fail() == true)
	{
		while (cin.fail()== true || signatur&lt;0)
		{
			cout &lt;&lt; endl &lt;&lt; &quot;Bitte eine gueltige Signatur ein Zahlenform eingeben&quot; &lt;&lt; endl;
			cin.clear();
			cin.sync();
			cout &lt;&lt; endl &lt;&lt; &quot;Signatur: &quot;;
			cin &gt;&gt; signatur;
		}
	}

	cout &lt;&lt; endl &lt;&lt; &quot;Titel: &quot;;
	cin.clear(); //Eingabepuffer löschen
	cin.sync();
	getline(cin,titel); //Einlesen und im String &quot;titel&quot; speichern
	if(titel.length() &gt; 12)
	{
		titel.erase(12,(titel.length()-12));
	}
}

void Medium::show_Medium()
{
	int x = 12;
	cout &lt;&lt; right &lt;&lt; setw(x) &lt;&lt; signatur &lt;&lt; &quot;    &quot; &lt;&lt; left &lt;&lt; setw(x) &lt;&lt; &quot;Medium&quot; 
		 &lt;&lt; setw(x) &lt;&lt; titel &lt;&lt; left &lt;&lt; setw(16) &lt;&lt; &quot;                    &quot;;

	if (LeihStatus == praesent)
	{
		cout &lt;&lt; &quot;vorh.&quot; &lt;&lt; endl;
	}
	else 
	{
		cout &lt;&lt; &quot;entl.&quot; &lt;&lt; endl;
	}
}

void Medium::entleihe_Medium()
{
	try
	{
		if (LeihStatus == verliehen)
		{
			throw Errorfail(signatur);
		}
		LeihStatus = verliehen;
		cout &lt;&lt; endl &lt;&lt; &quot;Das Medium wurde entliehen.&quot; &lt;&lt; endl &lt;&lt; endl;
	}
	catch (Errorfail e)
	{
		outfail = e.message();
		cout &lt;&lt; outfail;
	}
}

void Medium::ruecknahme_Medium()
{
	try
	{
		if (LeihStatus == praesent)
		{
			throw Errorfail(signatur);
		}
		LeihStatus = praesent;
		cout &lt;&lt; endl &lt;&lt; &quot;Das Medium wurde zurueckgenommen.&quot; &lt;&lt; endl &lt;&lt; endl;
	}
	catch (Errorfail e)
	{
		outfail = e.message();
		cout &lt;&lt; outfail;
	}
}

void Medium::printUeberschrift()
{
	int x = 12;
	cout &lt;&lt; right &lt;&lt; setw(x) &lt;&lt; &quot;Signatur&quot; &lt;&lt; &quot;    &quot; &lt;&lt; left &lt;&lt; setw(x) &lt;&lt; &quot;Typ&quot; 
		 &lt;&lt; setw(x) &lt;&lt; &quot;Titel&quot; &lt;&lt; right &lt;&lt; setw(16) &lt;&lt; &quot;Seiten/Dauer&quot; 
		 &lt;&lt; &quot;    &quot; &lt;&lt; left &lt;&lt; setw(x) &lt;&lt; &quot;Status&quot; &lt;&lt; endl &lt;&lt; endl;
}

//Methoden der Klasse Buch

Buch::Buch():Medium()
{     
     seitenzahl=0;                
}

void Buch::init_Buch()
{
	LeihStatus = praesent;
	cout &lt;&lt; endl &lt;&lt; &quot;Bitte Buchdaten eingeben: Signatur, Seitenzahl und Titel mit maximal 12 Zeichen&quot; &lt;&lt; endl &lt;&lt; endl;
	cout &lt;&lt; &quot;Signatur: &quot;;
	cin &gt;&gt; signatur;

	if(cin.fail() == true)
	{
		while (cin.fail()==true || signatur&lt;0)
		{
			cout &lt;&lt; endl &lt;&lt; &quot;Bitte eine gueltige Signatur ein Zahlenform eingeben&quot; &lt;&lt; endl;
			cin.clear();
			cin.sync();
			cout &lt;&lt; endl &lt;&lt; &quot;Signatur: &quot;;
			cin &gt;&gt; signatur;
		}
	}
	cout &lt;&lt; endl &lt;&lt; &quot;Titel: &quot;;
	cin.clear(); //Eingabepuffer löschen
	cin.sync();
	getline(cin,titel);
	if(titel.length() &gt; 12)
	{
		titel.erase(12,(titel.length()-12));
	}
	cout &lt;&lt; endl &lt;&lt; &quot;Seitenzahl: &quot;;
	cin.clear();
	cin.sync();
	cin &gt;&gt; seitenzahl;

	if (cin.fail() == true)
	{
		while (cin.fail()==true || seitenzahl&lt;0)
		{
			cout &lt;&lt; endl &lt;&lt; &quot;Fehlerhafte Seitenzahl! Bitte erneute Eingabe.&quot; &lt;&lt; endl;
			cout &lt;&lt; endl &lt;&lt; &quot;Seitenzahl: &quot;;
			cin.clear();
			cin.sync();
			cin &gt;&gt; seitenzahl;
		}
	} 
    return;     
}

void Buch::show_Medium()
{
	int x = 12;
	cout &lt;&lt; right &lt;&lt; setw(x) &lt;&lt; signatur &lt;&lt; &quot;    &quot; &lt;&lt; left &lt;&lt; setw(x) &lt;&lt; &quot;Buch&quot; 
		 &lt;&lt; setw(x) &lt;&lt; titel &lt;&lt; right &lt;&lt; setw(16) &lt;&lt; seitenzahl &lt;&lt; &quot;    &quot; &lt;&lt; left &lt;&lt; setw(x);

	if (LeihStatus == praesent)
	{
		cout &lt;&lt; &quot;vorh.&quot; &lt;&lt; endl;
	}
	else
	{
		cout &lt;&lt; &quot;entl.&quot; &lt;&lt; endl;
	}
}

void Buch::entleihe_Medium()
{
	try
	{
		if (LeihStatus == verliehen)
		{
			throw Errorfail(signatur);
		}
		LeihStatus = verliehen;
		cout &lt;&lt; endl &lt;&lt; &quot;Das Medium wurde entliehen.&quot; &lt;&lt; endl &lt;&lt; endl;
	}
	catch (Errorfail e)
	{
		e.message();
	}
}

void Buch::ruecknahme_Medium()
{
	try
	{
		if (LeihStatus == praesent)
		{
			throw Errorfail(signatur);
		}
		LeihStatus = praesent;
		cout &lt;&lt; endl &lt;&lt; &quot;Das Medium wurde zurückgenommen.&quot; &lt;&lt; endl &lt;&lt; endl;
	}
	catch (Errorfail e)
	{
		e.message();
	}
}

//Methoden der Klasse Video

Video::Video():Medium()
{  
     spieldauer=0;             
}

void Video::init_Video()
{
	LeihStatus = praesent;
	cout &lt;&lt; &quot;Bitte Videodaten eingeben: Signatur, Spieldauer und Titel mit maximal 12 Zeichen&quot; &lt;&lt; endl &lt;&lt; endl;
	cout &lt;&lt; &quot;Signatur: &quot;;
	cin &gt;&gt; signatur;

	if(cin.fail() == true)
	{

		while (cin.fail()==true || signatur&lt;0)
		{
			cout &lt;&lt; endl &lt;&lt; &quot;Bitte eine gueltige Signatur ein Zahlenform eingeben&quot; &lt;&lt; endl;
			cin.clear();
			cin.sync();
			cout &lt;&lt; endl &lt;&lt; &quot;Signatur: &quot;;
			cin &gt;&gt; signatur;
		}
	}
	cout &lt;&lt; endl &lt;&lt; &quot;Titel: &quot;;
	cin.clear();
	cin.sync();
	getline(cin,titel);
	if(titel.length() &gt; 12)
	{
		titel.erase(12,(titel.length()-12));
	}
	cout &lt;&lt; endl &lt;&lt; &quot;Spieldauer: &quot;;
	cin.clear();
	cin.sync();
	cin &gt;&gt; spieldauer;

	if (cin.fail() == true)
	{
		while (cin.fail()==true || spieldauer&lt;0)
		{
			cout &lt;&lt; endl &lt;&lt; &quot;Fehlerhafte Spieldauer! Bitte erneute Eingabe.&quot; &lt;&lt; endl;
			cout &lt;&lt; endl &lt;&lt; &quot;Spieldauer: &quot;;
			cin.clear();
			cin.sync();
			cin &gt;&gt; spieldauer;
		}
	} 
    return;
}

void Video::show_Medium()
{
	int x = 12;
	cout &lt;&lt; right &lt;&lt; setw(x) &lt;&lt; signatur &lt;&lt; &quot;    &quot; &lt;&lt; left &lt;&lt; setw(x) &lt;&lt; &quot;Video&quot; 
		 &lt;&lt; setw(x) &lt;&lt; titel &lt;&lt; right &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; setw(16) &lt;&lt; spieldauer &lt;&lt; &quot;    &quot; &lt;&lt; left &lt;&lt; setw(x);

	if (LeihStatus == praesent)
	{
		cout &lt;&lt; &quot;vorh.&quot; &lt;&lt; endl;
	}
	else
	{
		cout &lt;&lt; &quot;entl.&quot; &lt;&lt;endl;
	}
}

void Video::entleihe_Medium()
{
	try
	{
		if (LeihStatus == verliehen)
		{
			throw Errorfail(signatur);
		}
		LeihStatus = verliehen;
		cout &lt;&lt; endl &lt;&lt; &quot;Das Medium wurde entliehen.&quot; &lt;&lt; endl &lt;&lt; endl;
	}
	catch (Errorfail e)
	{
		e.message();
	}
}

void Video::ruecknahme_Medium()
{
	try
	{
		if (LeihStatus == praesent)
		{
			throw Errorfail(signatur);
		}
		LeihStatus = praesent;
		cout &lt;&lt; endl &lt;&lt; &quot;Das Medium wurde zurückgenommen.&quot; &lt;&lt; endl &lt;&lt; endl;
	}
	catch (Errorfail e)
	{
		e.message();
	}
}
</code></pre>
<p><strong>container.cpp</strong></p>
<pre><code class="language-cpp">#include &quot;container.h&quot;
using namespace std;

// Methoden der Klasse Container

Knoten::Knoten()
{
	next = NULL;
	item = NULL;
}

Container::Container()
{
	first = new Knoten();
	iterator = NULL;
}

bool Container::add(T* element) //Returnwert zur Fehlerkennung
{
	try
	{
		iterator = new Knoten();
	}
	catch(bad_alloc)
	{
		return false;
	}

	iterator-&gt;next = first-&gt;next;
	first-&gt;next = iterator;
	iterator-&gt;item = element;

	return true;
}

void Container::begin()
{
	iterator = first-&gt;next;
}

void Container::next()
{
	iterator = iterator-&gt;next;
}

T* Container::getItem()
{
		return iterator-&gt;item;
}

bool Container::endOfList()
{
	if (iterator != NULL)
		return false;
	else
		return true;
}
</code></pre>
<p><strong>container.h</strong></p>
<pre><code class="language-cpp">#ifndef CONTAINER_H
#define CONTAINER_H

#include &quot;Medium.h&quot;
using namespace std;

class Knoten
{
	friend class Container; //Klasse Container erhält Zugrif auf alle Elemente von Klasse Knoten
	Knoten* next;
	T* item;
	public:
		Knoten();
};

class Container 
{
	Knoten* first;
	Knoten* iterator; //Zeiger auf das aktuelle Containerelement

	public:
		Container(); //Konstruktor
		bool add(T* element);
		void begin();
		void next();
		T* getItem();
		bool endOfList();
};

#endif
</code></pre>
<p><strong>Medium.h</strong></p>
<pre><code class="language-cpp">#ifndef MEDIUM_H
#define MEDIUM_H

#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

enum Status {praesent, verliehen};
string outfail;

class Errorfail
{
	string buffer;
	public:
		ofstream dat_schr;
		ifstream dat_ausl;
		Errorfail(int _s)
		{
			int s = _s;
			dat_schr.open(&quot;Biberror.txt&quot;, ios::out);
			dat_schr &lt;&lt; &quot;Fehler bei Signatur &quot; &lt;&lt; s &lt;&lt; endl;
			dat_schr.close();
		}
		string message()
		{
			dat_ausl.open(&quot;Biberror.txt&quot;, ios::in);
			getline(dat_ausl,buffer);
			dat_ausl.close();
			return buffer;
		}
};

class Medium
{
	protected://Zugriff nur aus abgeleiteten Klassen möglich.
		string titel;
		Status LeihStatus;
		int signatur;

	public:	
		Medium();
			~Medium(); //Destruktor
		void init_Medium();
			virtual void show_Medium();		  //virtual nötig zum Aufruf von show_Medium in den abgeleiteten Klassen
			virtual void entleihe_Medium()=0; // rein virtuelle Funktion, abstrakte Basisklasse
		void ruecknahme_Medium();
		static void printUeberschrift();
		int get_signatur() 
		{
			return signatur;
		}			
};

typedef Medium T;

class Buch : public Medium
{
	int seitenzahl;

	public:
		Buch();
			~Buch(){} //Destruktor
		void init_Buch();
		void show_Medium();
		void entleihe_Medium();
		void ruecknahme_Medium();
		int get_signatur() 
		{
			return signatur;
		}
};

class Video : public Medium
{
	double spieldauer;

	public:
		Video();
			~Video(){} //Destruktor
		void init_Video();
		void show_Medium();
		void entleihe_Medium();
		void ruecknahme_Medium();
		int get_signatur() 
		{
			return signatur;
		}
};
#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1306954</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1306954</guid><dc:creator><![CDATA[bodensee14]]></dc:creator><pubDate>Fri, 15 Jun 2007 21:52:02 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler c2248 on Fri, 15 Jun 2007 22:51:38 GMT]]></title><description><![CDATA[<p>hmm</p>
<pre><code class="language-cpp">#if !defined(ERROR_TO_FILE_H__INCLUDED)
#define ERROR_TO_FILE_H__INCLUDED

#include &lt;fstream&gt;
#include &lt;string&gt;

template&lt;typename T&gt;
class error_to_file
{
public:
    error_to_file(const T&amp; data) : m_data(data), m_stream(&quot;error.log&quot;, std::ios::out | std::ios::app)
    {
        std::ostringstream ss;
        ss &lt;&lt; &quot;FEHLER: &quot; &lt;&lt; m_data &lt;&lt; std::endl;
        m_dataString = ss.str();
        m_stream &lt;&lt; m_dataString &lt;&lt; std::endl;
    }
    const std::string&amp; message() const { return m_dataString; }

private:
    T m_data;
    std::ofstream m_stream;
    std::string m_dataString;
};

#endif // ERROR_TO_FILE_H__INCLUDED
</code></pre>
<pre><code class="language-cpp">#if !defined(INTERFACE_MEDIUM__INCLUDED)
#define INTERFACE_MEDIUM__INCLUDED

#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;iomanip&gt;

class IMedium
{
public:   
	IMedium() : m_lend(false), m_sig(0) {}
	~IMedium()							{}

public:
	virtual void init()	
	{ 
		std::cout &lt;&lt; &quot;Signatur: &quot; &lt;&lt; std::flush; std::cin &gt;&gt; m_sig; 
		std::cout &lt;&lt; &quot;Titel: &quot; &lt;&lt; std::flush; std::getline(std::cin, m_title); 
		if (m_title.length() &gt; 12) m_title.erase(12);
	}

	virtual void show()		
	{  
		std::cout &lt;&lt; std::right &lt;&lt; std::setw(12) &lt;&lt; m_sig &lt;&lt; &quot;    &quot; &lt;&lt; std::left &lt;&lt; std::setw(12) &lt;&lt; &quot;Medium&quot; &lt;&lt; std::setw(12) &lt;&lt; m_title &lt;&lt; std::left &lt;&lt; std::setw(16) &lt;&lt; &quot;                   &quot; &lt;&lt; (m_lend ? &quot;ausg.&quot; : &quot;vorh.&quot;) &lt;&lt; std::endl;	
	}

	virtual void lend()		
	{ 
		try
		{
			if (m_lend == true)
				throw error_to_file&lt;int&gt;(m_sig);
			m_lend = true;
			std::cout &lt;&lt; std::endl &lt;&lt; &quot;Das Medium wurde verliehen!&quot; &lt;&lt; std::endl &lt;&lt; std::endl;
		}
		catch (const error_to_file&lt;int&gt;&amp; e)	{	std::cerr &lt;&lt; e.message() &lt;&lt; std::endl;	}
	}

	virtual void recede()
	{
		try
		{
			if (m_lend == false)
				throw error_to_file&lt;int&gt;(m_sig);
			m_lend = false;
			std::cout &lt;&lt; std::endl &lt;&lt; &quot;Das Medium wurde zurückgenommen!&quot; &lt;&lt; std::endl &lt;&lt; std::endl;
		}
		catch (const error_to_file&lt;int&gt;&amp; e)	{	std::cerr &lt;&lt; e.message() &lt;&lt; std::endl;	} 
	}

public:
	int get_signature() const	{	return m_sig;	}      

protected:
	std::string		m_title;
	bool			m_lend;
	int				m_sig;
}; 

#endif // INTERFACE_MEDIUM__INCLUDED
</code></pre>
<pre><code class="language-cpp">#if !defined (VIDEO_H__INCLUDED)
#define VIDEO_H__INCLDED

class Video : public IMedium
{
public:
	Video() : m_timePlay(0.0)	{}
	~Video()					{}

public:
	void init()
	{
		std::cout &lt;&lt; &quot;.Video:&quot; &lt;&lt; std::endl;
		do {
			std::cin.clear(); 
			std::cin.sync();
			std::cout &lt;&lt; &quot;.:Signatur: &quot; &lt;&lt; std::flush;
		} while (!(std::cin &gt;&gt; m_sig));
		std::cout &lt;&lt; &quot;.:Titel: &quot; &lt;&lt; std::flush;
		std::getline(std::cin, m_title);
		m_title.erase(12);
		do {
			std::cin.clear(); 
			std::cin.sync();
			std::cout &lt;&lt; &quot;.:Spieldauer: &quot; &lt;&lt; std::flush;
		} while (!(std::cin &gt;&gt; m_timePlay));
	}

	void show()
	{
		std::cout &lt;&lt; std::right &lt;&lt; std::setw(12) &lt;&lt; m_sig &lt;&lt; &quot;    &quot; &lt;&lt; std::left &lt;&lt; std::setw(12) &lt;&lt; &quot;Video&quot; &lt;&lt; std::setw(12) &lt;&lt; m_title &lt;&lt; std::right &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; std::setw(16) &lt;&lt; m_timePlay &lt;&lt; &quot;    &quot; &lt;&lt; std::left &lt;&lt; std::setw(12) &lt;&lt; (m_lend == true ? &quot;ausg.&quot; : &quot;vorh.&quot;) &lt;&lt; std::endl;
	}

private:
	double m_timePlay;
}; 

#endif // VIDEO_H__INCLUDED
</code></pre>
<pre><code class="language-cpp">#if !defined (BOOK_H__INCLUDED)
#define BOOK_H__INCLUDED

class Book : public IMedium
{
public:
	Book() : m_countPage(0)		{}
	~Book()						{}

public:
	void init()
	{
		std::cout &lt;&lt; &quot;.Buch:&quot; &lt;&lt; std::endl;
		do {
			std::cin.clear(); 
			std::cin.sync();
			std::cout &lt;&lt; &quot;.:Signatur: &quot; &lt;&lt; std::flush;
		} while (!(std::cin &gt;&gt; m_sig));
		std::cout &lt;&lt; &quot;.:Titel: &quot; &lt;&lt; std::flush;
		std::getline(std::cin, m_title);
		m_title.erase(12);
		do {
			std::cin.clear(); 
			std::cin.sync();
			std::cout &lt;&lt; &quot;.:Seitenanzahl: &quot; &lt;&lt; std::flush;
		} while (!(std::cin &gt;&gt; m_countPage));
	}

	void show()
	{
		std::cout &lt;&lt; std::right &lt;&lt; std::setw(12) &lt;&lt; m_sig &lt;&lt; &quot;    &quot; &lt;&lt; std::left &lt;&lt; std::setw(12) &lt;&lt; &quot;Buch&quot; &lt;&lt; std::setw(12) &lt;&lt; m_title &lt;&lt; std::right &lt;&lt; std::setw(16) &lt;&lt; m_countPage &lt;&lt; &quot;    &quot; &lt;&lt; std::left &lt;&lt; std::setw(12) &lt;&lt; (m_lend == true ? &quot;ausg.&quot; : &quot;vorh.&quot;) &lt;&lt; std::endl;
	}

private:
	unsigned short	m_countPage;
}; 

#endif // BOOK_H__INCLUDED
</code></pre>
<pre><code class="language-cpp">int main()
{
	std::vector&lt;IMedium&gt; media;
	char sel = 'a';

    while (sel != 'q')
    {
		std::cout &lt;&lt; &quot;(l) Medien anzeigen&quot; &lt;&lt; std::endl;
		std::cout &lt;&lt; &quot;(b) Neues Buch anlegen&quot; &lt;&lt; std::endl;
		std::cout &lt;&lt; &quot;(v) Neues Video anlegen&quot; &lt;&lt; std::endl;
		std::cout &lt;&lt; &quot;(e Signatur) Entleihen eines Mediums&quot; &lt;&lt; std::endl;
		std::cout &lt;&lt; &quot;(r Signatur) Ruecknahme eines Mediums&quot; &lt;&lt; std::endl;
		std::cout &lt;&lt; &quot;(q) Programm beenden&quot; &lt;&lt; std::endl;

		do {
			std::cin.clear();
			std::cin.sync();
			std::cout &lt;&lt; &quot;Auswahl: &quot; &lt;&lt; std::flush;
		} while (!(std::cin &gt;&gt; sel));

        switch (sel)
        {
            case 'b':
            case 'B': 
				{
					media.push_back(Book());
					media[media.size() - 1].init();
				} break;
            case 'v':
            case 'V': 
				{
					media.push_back(Video());
					media[media.size() - 1].init();
				} break;
            case 'l':
            case 'L': 
				{
					for (std::vector&lt;IMedia&gt;::iterator it = media.begin(); it != media.end(); ++it)
						(*it).show();
				} break;
            case 'e':
            case 'E':
				{
					int sig;
					do {
						std::cin.clear();
						std::cin.sync();
						std::cout &lt;&lt; &quot;Signatur: &quot; &lt;&lt; std::flush;
					} while (!(std::cin &gt;&gt; sel));

					bool found = false;
					for (std::vector&lt;IMedia&gt;::iterator it = media.begin(); it != media.end(); ++it)
						if ((*it).get_signatur() == sig) { found = true; (*it).lend(); break; }

						std::cerr &lt;&lt; &quot;Kein Medium mit dieser Signatur vorhanden!&quot; &lt;&lt; std::endl;
				} break;
            case 'r':
            case 'R': 
				{
					int sig;
					do {
						std::cin.clear();
						std::cin.sync();
						std::cout &lt;&lt; &quot;Signatur: &quot; &lt;&lt; std::flush;
					} while (!(std::cin &gt;&gt; sel));

					bool found = false;
					for (std::vector&lt;IMedia&gt;::iterator it = media.begin(); it != media.end(); ++it)
						if ((*it).get_signatur() == sig) { found = true; (*it).recede(); break; }

						std::cerr &lt;&lt; &quot;Kein Medium mit dieser Signatur vorhanden!&quot; &lt;&lt; std::endl;
				} break;
            default: 
				std::cerr &lt;&lt; &quot;Menüpunkt nicht vorhanden!&quot; &lt;&lt; std::endl;
        }
    }
}
</code></pre>
<p><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>
]]></description><link>https://www.c-plusplus.net/forum/post/1306979</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1306979</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Fri, 15 Jun 2007 22:51:38 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler c2248 on Sat, 16 Jun 2007 01:47:47 GMT]]></title><description><![CDATA[<p>(D)Evil: Das ist ganz schön lang, dafür dass es nicht durch den Compiler gejagt wurde <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>Das Problem ist</p>
<pre><code class="language-cpp">throw Errorfail(signatur);
</code></pre>
<p>Dafür muss Errorfail kopiert werden, was nicht möglich ist, da es Streammember hat und Streams per se nicht kopierbar sind. Es sind noch ein paar mehr Probleme im Code, aber die willst du sicher selber finden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1307006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1307006</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sat, 16 Jun 2007 01:47:47 GMT</pubDate></item></channel></rss>