<?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[Findet ihr spontan n Fehler...amverzweifeln]]></title><description><![CDATA[<p>Hi</p>
<p>der Titel sagt alles...hier der Code:</p>
<pre><code class="language-cpp">/* ============================================================ */
// AddNewEntry: Fügt ein neuen Eintrag ein.
//
bool CPlaylist::AddNewEntry(char* pszEntryName, PENTRYDATA pedData)
{	
	if(pszEntryName == NULL || pedData == NULL)
		return (false);

	if(this-&gt;IsEmpty())
	{
		this-&gt;_dbEntryArray = new CListEntry*;

		this-&gt;_dbEntryArray[0] = new CListEntry;
		this-&gt;_dbEntryArray[0]-&gt;SetEntryName(pszEntryName);
		this-&gt;_dbEntryArray[0]-&gt;SetEntryData(pedData);

		this-&gt;_ulTotalEntries += 1;
		return (true);
	}
	else
	{
		unsigned long ulCount;		
		CListEntry** dpTemp = new CListEntry*[this-&gt;_ulTotalEntries];

		for(ulCount = 0L; ulCount &lt; this-&gt;_ulTotalEntries; ulCount++)
			dpTemp[ulCount] = this-&gt;_dbEntryArray[ulCount];

		delete [] this-&gt;_dbEntryArray;

		std::cout &lt;&lt; this-&gt;_dbEntryArray &lt;&lt; std::endl;

		this-&gt;_dbEntryArray = new CListEntry*[this-&gt;_ulTotalEntries + 1];
		MessageBox(0,0,0,0);

		for(ulCount = 0L; ulCount &lt; this-&gt;_ulTotalEntries; ulCount++)
			this-&gt;_dbEntryArray[ulCount] = dpTemp[ulCount];

		delete [] dpTemp;

		this-&gt;_dbEntryArray[ulCount + 1] = new CListEntry;
		this-&gt;_dbEntryArray[ulCount + 1]-&gt;SetEntryName(pszEntryName);
		this-&gt;_dbEntryArray[ulCount + 1]-&gt;SetEntryData(pedData);

		this-&gt;_ulTotalEntries += 1;		
		return (true);
	}
}
</code></pre>
<p>THX a lot!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/148834/findet-ihr-spontan-n-fehler-amverzweifeln</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 04:00:53 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/148834.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 May 2006 20:10:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Findet ihr spontan n Fehler...amverzweifeln on Tue, 30 May 2006 20:10:44 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>der Titel sagt alles...hier der Code:</p>
<pre><code class="language-cpp">/* ============================================================ */
// AddNewEntry: Fügt ein neuen Eintrag ein.
//
bool CPlaylist::AddNewEntry(char* pszEntryName, PENTRYDATA pedData)
{	
	if(pszEntryName == NULL || pedData == NULL)
		return (false);

	if(this-&gt;IsEmpty())
	{
		this-&gt;_dbEntryArray = new CListEntry*;

		this-&gt;_dbEntryArray[0] = new CListEntry;
		this-&gt;_dbEntryArray[0]-&gt;SetEntryName(pszEntryName);
		this-&gt;_dbEntryArray[0]-&gt;SetEntryData(pedData);

		this-&gt;_ulTotalEntries += 1;
		return (true);
	}
	else
	{
		unsigned long ulCount;		
		CListEntry** dpTemp = new CListEntry*[this-&gt;_ulTotalEntries];

		for(ulCount = 0L; ulCount &lt; this-&gt;_ulTotalEntries; ulCount++)
			dpTemp[ulCount] = this-&gt;_dbEntryArray[ulCount];

		delete [] this-&gt;_dbEntryArray;

		std::cout &lt;&lt; this-&gt;_dbEntryArray &lt;&lt; std::endl;

		this-&gt;_dbEntryArray = new CListEntry*[this-&gt;_ulTotalEntries + 1];
		MessageBox(0,0,0,0);

		for(ulCount = 0L; ulCount &lt; this-&gt;_ulTotalEntries; ulCount++)
			this-&gt;_dbEntryArray[ulCount] = dpTemp[ulCount];

		delete [] dpTemp;

		this-&gt;_dbEntryArray[ulCount + 1] = new CListEntry;
		this-&gt;_dbEntryArray[ulCount + 1]-&gt;SetEntryName(pszEntryName);
		this-&gt;_dbEntryArray[ulCount + 1]-&gt;SetEntryData(pedData);

		this-&gt;_ulTotalEntries += 1;		
		return (true);
	}
}
</code></pre>
<p>THX a lot!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1068395</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1068395</guid><dc:creator><![CDATA[Oha!]]></dc:creator><pubDate>Tue, 30 May 2006 20:10:44 GMT</pubDate></item><item><title><![CDATA[Reply to Findet ihr spontan n Fehler...amverzweifeln on Tue, 30 May 2006 20:16:11 GMT]]></title><description><![CDATA[<p>Oha! schrieb:</p>
<blockquote>
<pre><code class="language-cpp">this-&gt;_dbEntryArray[ulCount] = new CListEntry;
		this-&gt;_dbEntryArray[ulCount]-&gt;SetEntryName(pszEntryName);
		this-&gt;_dbEntryArray[ulCount]-&gt;SetEntryData(pedData);
</code></pre>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1068399</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1068399</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Tue, 30 May 2006 20:16:11 GMT</pubDate></item><item><title><![CDATA[Reply to Findet ihr spontan n Fehler...amverzweifeln on Tue, 30 May 2006 20:46:16 GMT]]></title><description><![CDATA[<p>Muhahah mir fällt grad auf, das ich totale scheiße <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="😃"
    /> gepostet hab: Also hier n bissl Hintergrundwissen^^:</p>
<p>- WinXP<br />
- Mircrsoft Visual C++ 6.0</p>
<p>- Der Debug Modus meint, das hier:</p>
<pre><code class="language-cpp">this-&gt;_dbEntryArray = new CListEntry*[this-&gt;_ulTotalEntries + 1];
</code></pre>
<p>n Speicherfehlgriff statt findet... (&quot;Access Violation&quot;)</p>
<p>- also es geht wie vll schon ersichtlich um eine Klasse die ein Zeiger Array enthält (ListenKlasse, aufbauend auf Array, keine verkettete Liste), die auf Objekten der Klasse CListEntry (ein Eintrag in der Liste) besteht...die Methode fügt einen neuen EIntrag in die Liste ein...beim ersten Aufruf funzt das auch, beim 2. schon nicht mehr</p>
<p>- der konstruktor init. die elemente so:</p>
<pre><code class="language-cpp">CPlaylist::CPlaylist(void)
{
	this-&gt;_dbEntryArray		= NULL;
	this-&gt;_ulTotalEntries	= 0;
}
</code></pre>
<p>so nochmal sry wg. meinem schlechten Code...peinlich... <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="🙄"
    /><br />
wär nett wenn nochmal jmd. drauf gucken könnte... <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/1068420</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1068420</guid><dc:creator><![CDATA[Oha!]]></dc:creator><pubDate>Tue, 30 May 2006 20:46:16 GMT</pubDate></item><item><title><![CDATA[Reply to Findet ihr spontan n Fehler...amverzweifeln on Tue, 30 May 2006 22:04:18 GMT]]></title><description><![CDATA[<p>Muhahah mir fällt grad auf, das ich totale scheiße <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="😃"
    /> gepostet hab: Also hier n bissl Hintergrundwissen^^:</p>
<p>- WinXP<br />
- Mircrsoft Visual C++ 6.0</p>
<p>- Der Debug Modus meint, das hier:</p>
<pre><code class="language-cpp">this-&gt;_dbEntryArray = new CListEntry*[this-&gt;_ulTotalEntries + 1];
</code></pre>
<p>n Speicherfehlgriff statt findet... (&quot;Access Violation&quot;)</p>
<p>- also es geht wie vll schon ersichtlich um eine Klasse die ein Zeiger Array enthält (ListenKlasse, aufbauend auf Array, keine verkettete Liste), die auf Objekten der Klasse CListEntry (ein Eintrag in der Liste) besteht...die Methode fügt einen neuen EIntrag in die Liste ein...beim ersten Aufruf funzt das auch, beim 2. schon nicht mehr</p>
<p>- der konstruktor init. die elemente so:</p>
<pre><code class="language-cpp">CPlaylist::CPlaylist(void)
{
	this-&gt;_dbEntryArray		= NULL;
	this-&gt;_ulTotalEntries	= 0;
}
</code></pre>
<p>so nochmal sry wg. meinem schlechten Code...peinlich... <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="🙄"
    /><br />
wär nett wenn nochmal jmd. drauf gucken könnte... <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/1068454</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1068454</guid><dc:creator><![CDATA[Oha!]]></dc:creator><pubDate>Tue, 30 May 2006 22:04:18 GMT</pubDate></item><item><title><![CDATA[Reply to Findet ihr spontan n Fehler...amverzweifeln on Wed, 31 May 2006 06:32:45 GMT]]></title><description><![CDATA[<p>Oha! schrieb:</p>
<blockquote>
<p>Muhahah mir fällt grad auf, das ich totale scheiße <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="😃"
    /> gepostet hab: Also hier n bissl Hintergrundwissen^^:</p>
<p>- WinXP<br />
- Mircrsoft Visual C++ 6.0</p>
<p>- Der Debug Modus meint, das hier:</p>
<pre><code class="language-cpp">this-&gt;_dbEntryArray = new CListEntry*[this-&gt;_ulTotalEntries + 1];
</code></pre>
<p>n Speicherfehlgriff statt findet... (&quot;Access Violation&quot;)</p>
</blockquote>
<p>Du machst es dir sowieso etwas zu schwer <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="😉"
    /> (es reicht aus, deine gesamten Daten einmal zu kopieren:</p>
<pre><code class="language-cpp">temp = new CListEntry*[_ulTotalEntries+1];
for(i=i;i&lt;_ulTotalEntries;++i)
  temp[i]=_dbEntryArray[i];
temp [_ulTotal_Entries] = new CListEntry;
//neues Element füllen
delete[]_dbEntryArray;
_dbEntryArray = temp;
</code></pre>
<p>PS: Und wozu gibst du eigentlich einen Zeiger aus, den du direkt vorher freigegeben hast?</p>
<blockquote>
<p>- also es geht wie vll schon ersichtlich um eine Klasse die ein Zeiger Array enthält (ListenKlasse, aufbauend auf Array, keine verkettete Liste), die auf Objekten der Klasse CListEntry (ein Eintrag in der Liste) besteht...die Methode fügt einen neuen EIntrag in die Liste ein...beim ersten Aufruf funzt das auch, beim 2. schon nicht mehr</p>
</blockquote>
<p>Statt dir selber etwas zusammenzubauen, solltest du lieber auf vorgefertigte Methoden zurückgreifen: std::vector&lt;&gt; oder std::deque&lt;&gt; wären womöglich passend.</p>
<p>PS: Und ob es gut geht, einen per new angelegten Pointer mit delete[] freizugeben, ist auch Glückssache.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1068508</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1068508</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 31 May 2006 06:32:45 GMT</pubDate></item><item><title><![CDATA[Reply to Findet ihr spontan n Fehler...amverzweifeln on Wed, 31 May 2006 15:41:07 GMT]]></title><description><![CDATA[<blockquote>
<p>PS: Und ob es gut geht, einen per new angelegten Pointer mit delete[] freizugeben, ist auch Glückssache.</p>
</blockquote>
<p>em wo denn ?</p>
<p>thX schonmal ^^</p>
<p>PS: die Ausgabe war nur n Test...für was anderes ... vergessen weg zu machen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1068920</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1068920</guid><dc:creator><![CDATA[Oha!]]></dc:creator><pubDate>Wed, 31 May 2006 15:41:07 GMT</pubDate></item><item><title><![CDATA[Reply to Findet ihr spontan n Fehler...amverzweifeln on Wed, 31 May 2006 16:13:09 GMT]]></title><description><![CDATA[<p>Er meint sicher dieses delete</p>
<pre><code class="language-cpp">delete [] this-&gt;_dbEntryArray;
</code></pre>
<p>weiter oben steht das hier</p>
<pre><code class="language-cpp">this-&gt;_dbEntryArray = new CListEntry*;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1068953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1068953</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Wed, 31 May 2006 16:13:09 GMT</pubDate></item><item><title><![CDATA[Reply to Findet ihr spontan n Fehler...amverzweifeln on Wed, 31 May 2006 16:42:20 GMT]]></title><description><![CDATA[<p>ok soweit so gut CStolls Tipps waren gut *THUMPSUP* funzt!!</p>
<p>nochmal ne Frage: Ich organisier ja alle Einträge in einem Array in Form eines Pointer Array...<br />
Wenn ich jetzt Zugriffmethoden implementiere, die dann bspw. das erste Element ermitteln sollen...geht folgendes NICHT bzw. ist 'unzureichend' bezogen auf den Return Wert:</p>
<p>Mit Zeigern:<br />
Positiv:<br />
- Wenn Liste leer, dann wird Error durch Return Wert NULL gekennz.<br />
Negativ:<br />
- Zeiger kann überschrieben werden, Zeiger Array enthält dann Fehler!<br />
- mit einer const CListEntry* lässt sich dann die Methoden der Klasse nicht mehr aufrufen...er meckert wg. nem Const-Objekt</p>
<pre><code class="language-cpp">CListEntry* CPlaylist::GetFirstEntry(void)
{
	if(this-&gt;IsEmpty())
		return (NULL);

	return (this-&gt;_dbEntryArray[0]);
}
</code></pre>
<p>Mit Referenzen:<br />
Positiv:<br />
- Adresse kann nicht überschrieben werden<br />
Negativ:<br />
- keine Kennzeichnung eines Errors...durch eine leere Liste bswp.</p>
<pre><code class="language-cpp">CListEntry&amp; CPlaylist::GetFirstEntry(void)
{
	if(this-&gt;IsEmpty())
		return (NULL);

	return (*(this-&gt;_dbEntryArray[0]));
}
</code></pre>
<p>Habt ihr vll. n' Vorschlag, wie ich das lösen könnte ... oder vll. n' Fehler gefunden <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>
<p>THX schon mal <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>PS: Hier nochmal mein Beispielaufruf mit const-Zeiger:</p>
<pre><code class="language-cpp">// ...
// cPlaylist ist Objekt der Klasse CPlaylist und wurde vorher KORREKT
// initialisiert.
// ...
char buf[100];
const CListEntry* ptr = cPlaylist.GetLastEntry();
if(ptr != NULL)
   ptr-&gt;GetEntryName(buf, 100); // Hier tritt der Fehler auf!

cout &lt;&lt; buf &lt;&lt; endl;
</code></pre>
<p>...hier die Fehlermeldung des Compilers:</p>
<pre><code>error C2662: 'GetEntryName' : this-Zeiger kann nicht von 'const class CListEntry' in 'class CListEntry &amp;' konvertiert werden
        Durch die Konvertierung gehen Qualifizierer verloren
CListEntry.cpp
</code></pre>
<p>danke nochmal für hlp! <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/1068974</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1068974</guid><dc:creator><![CDATA[Oha!]]></dc:creator><pubDate>Wed, 31 May 2006 16:42:20 GMT</pubDate></item><item><title><![CDATA[Reply to Findet ihr spontan n Fehler...amverzweifeln on Wed, 31 May 2006 16:50:30 GMT]]></title><description><![CDATA[<p>Mach alle Funktionen, die nicht schreibend zugreifen (also alle get und is Methoden) const:</p>
<pre><code class="language-cpp">bool isEmpty () const
// bei allen
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1068978</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1068978</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Wed, 31 May 2006 16:50:30 GMT</pubDate></item><item><title><![CDATA[Reply to Findet ihr spontan n Fehler...amverzweifeln on Wed, 31 May 2006 17:06:29 GMT]]></title><description><![CDATA[<p>und was ist mit denen die schreibend darauf zugreifen...die sollen ja auch verfügbar sein...!!!</p>
<p>der schreibschutz soll sich lediglich auf den ptr im Array beziehen!</p>
<p>DANKE !</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1068988</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1068988</guid><dc:creator><![CDATA[Oha!]]></dc:creator><pubDate>Wed, 31 May 2006 17:06:29 GMT</pubDate></item></channel></rss>