<?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[Problem mit delete()]]></title><description><![CDATA[<p>Meine Klasse hat folgenden Aufbau:</p>
<pre><code class="language-cpp">class TUIManager
{ //Manager for the OpenGL-SDL-userinterface
  private: 

    ...

    vector&lt;TTF_Font*&gt; FontList;		//stores all fonts which are used in the GUI
    vector&lt;string*&gt; FontNameTable;	//stores pointers to the names of the fonts. The i-th string is the name of the font with ID=i.

    ...

  public:
    // Constructor
    TUIManager();

    // Destructor
    ~TUIManager();

    //----------------------Methodes------------------------------------

    ...

    // Returns true if the font was deleted, else false.
    bool deleteFont(int fontID);
};
</code></pre>
<pre><code class="language-cpp">// Returns true if the font was deleted, else false.
bool TUIManager::deleteFont(int fontID)
{
	if ( (fontID &gt;= 0)&amp;&amp;( (unsigned int)fontID &lt; FontList.size() ) )
	{
		if (FontList[fontID] == NULL) return true;

		TTF_CloseFont(FontList[fontID]);
		delete(FontList[fontID]);
		FontList[fontID] = NULL;
		delete(FontNameTable[fontID]);
		FontNameTable[fontID] = NULL;
		return true;
	}

	return false;
}
</code></pre>
<p>Beim aufruf der Methode deleteFont() bekomme ich bei</p>
<pre><code class="language-cpp">delete(FontList[fontID]);
</code></pre>
<p>folgenden Compiler-Fehler:</p>
<pre><code>../src/TUIManager.cpp: In member function `bool TUIManager::deleteFont(int)':
../src/TUIManager.cpp:546: warning: possible problem detected in invocation of delete operator:
../src/TUIManager.cpp:546: warning: invalid use of undefined type `struct _TTF_Font'
C:/Programmieren/Imported_Libs/SDL_ttf-2.0.7/include/SDL_ttf.h:80: warning: forward declaration of `struct _TTF_Font'
../src/TUIManager.cpp:546: note: neither the destructor nor the class-specific operator delete will be called, 
  even if they are declared when the class is defined.
</code></pre>
<p>Im header ist die datei SDL_TTF includiert, welche die Klasse TTF_Font bereitstellt.</p>
<p>Was mach ich falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/133775/problem-mit-delete</link><generator>RSS for Node</generator><lastBuildDate>Fri, 28 Aug 2026 01:14:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/133775.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 20 Jan 2006 16:35:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit delete() on Fri, 20 Jan 2006 16:35:03 GMT]]></title><description><![CDATA[<p>Meine Klasse hat folgenden Aufbau:</p>
<pre><code class="language-cpp">class TUIManager
{ //Manager for the OpenGL-SDL-userinterface
  private: 

    ...

    vector&lt;TTF_Font*&gt; FontList;		//stores all fonts which are used in the GUI
    vector&lt;string*&gt; FontNameTable;	//stores pointers to the names of the fonts. The i-th string is the name of the font with ID=i.

    ...

  public:
    // Constructor
    TUIManager();

    // Destructor
    ~TUIManager();

    //----------------------Methodes------------------------------------

    ...

    // Returns true if the font was deleted, else false.
    bool deleteFont(int fontID);
};
</code></pre>
<pre><code class="language-cpp">// Returns true if the font was deleted, else false.
bool TUIManager::deleteFont(int fontID)
{
	if ( (fontID &gt;= 0)&amp;&amp;( (unsigned int)fontID &lt; FontList.size() ) )
	{
		if (FontList[fontID] == NULL) return true;

		TTF_CloseFont(FontList[fontID]);
		delete(FontList[fontID]);
		FontList[fontID] = NULL;
		delete(FontNameTable[fontID]);
		FontNameTable[fontID] = NULL;
		return true;
	}

	return false;
}
</code></pre>
<p>Beim aufruf der Methode deleteFont() bekomme ich bei</p>
<pre><code class="language-cpp">delete(FontList[fontID]);
</code></pre>
<p>folgenden Compiler-Fehler:</p>
<pre><code>../src/TUIManager.cpp: In member function `bool TUIManager::deleteFont(int)':
../src/TUIManager.cpp:546: warning: possible problem detected in invocation of delete operator:
../src/TUIManager.cpp:546: warning: invalid use of undefined type `struct _TTF_Font'
C:/Programmieren/Imported_Libs/SDL_ttf-2.0.7/include/SDL_ttf.h:80: warning: forward declaration of `struct _TTF_Font'
../src/TUIManager.cpp:546: note: neither the destructor nor the class-specific operator delete will be called, 
  even if they are declared when the class is defined.
</code></pre>
<p>Im header ist die datei SDL_TTF includiert, welche die Klasse TTF_Font bereitstellt.</p>
<p>Was mach ich falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/971557</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/971557</guid><dc:creator><![CDATA[Anfänger06]]></dc:creator><pubDate>Fri, 20 Jan 2006 16:35:03 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit delete() on Fri, 20 Jan 2006 17:10:44 GMT]]></title><description><![CDATA[<p>Fehlen auch noch Infos, oder wieso könnt ihr mir nicht weiterhelfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/971583</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/971583</guid><dc:creator><![CDATA[Anfänger06]]></dc:creator><pubDate>Fri, 20 Jan 2006 17:10:44 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit delete() on Fri, 20 Jan 2006 17:37:51 GMT]]></title><description><![CDATA[<p>TTF_CloseFont() gibt den Speicher frei und invalidiert dadurch den Zeiger. Da gibt es nichts mit delete zu loeschen, zumal Du es auch nicht mit new erzeugst.</p>
<p>Siehe auch: <a href="http://jcatki.no-ip.org/SDL_ttf/SDL_ttf.html#SEC18" rel="nofollow">http://jcatki.no-ip.org/SDL_ttf/SDL_ttf.html#SEC18</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/971597</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/971597</guid><dc:creator><![CDATA[Apollon]]></dc:creator><pubDate>Fri, 20 Jan 2006 17:37:51 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit delete() on Fri, 20 Jan 2006 17:42:19 GMT]]></title><description><![CDATA[<p>Danke. Da hätte ich selber drauf kommen müssen.</p>
<p>Es sind immer die Einfachsten Dinge die einen am längsten aufhalten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/971599</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/971599</guid><dc:creator><![CDATA[Anfänger06]]></dc:creator><pubDate>Fri, 20 Jan 2006 17:42:19 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit delete() on Fri, 20 Jan 2006 22:53:19 GMT]]></title><description><![CDATA[<p>Keine Ursache.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/971801</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/971801</guid><dc:creator><![CDATA[Apollon]]></dc:creator><pubDate>Fri, 20 Jan 2006 22:53:19 GMT</pubDate></item></channel></rss>