<?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[C++ wie wird hier die Schnittstelle definiert!?]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>ich hab folgenden Codeschnippsel (in QT) gefunden!?</p>
<pre><code>// this struct calls &quot;myCustomDeallocator&quot; to delete the pointer
            struct ScopedPointerCustomDeleter2
            {
                static inline void cleanup(int *pointer)
                {
                    delete pointer;
                }
            };

            // QScopedPointer using a custom deleter:
            QScopedPointer&lt;int, ScopedPointerCustomDeleter2&gt; customPointer(new int);
</code></pre>
<p>Dem Object QScopedPointer kann man ein custom Deleter übergeben, in dem fall &quot;ScopedPointerCustomDeleter2&quot; aber wo is hier nun die schnittstelle zu funktion<br />
&quot;void cleanup(int *pointer)&quot; ? Die struktur muss diese funktion enhalten dass es funkltioniert! aber wie macht der compiler das?</p>
<p>ich kenne es nur aus C#, da müsstte die struktur eine Interface implementieren, oder ich würde via Refelctions checlen ob die funktion v orhanden ist!<br />
Aber wie funktioniert das hier?</p>
<p>Danke <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="🙂"
    /> Ich sehe schon c++ ist wieder ganz neue für mich^^</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/329387/c-wie-wird-hier-die-schnittstelle-definiert</link><generator>RSS for Node</generator><lastBuildDate>Mon, 25 May 2026 20:33:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/329387.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Nov 2014 06:41:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C++ wie wird hier die Schnittstelle definiert!? on Thu, 20 Nov 2014 06:41:04 GMT]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>ich hab folgenden Codeschnippsel (in QT) gefunden!?</p>
<pre><code>// this struct calls &quot;myCustomDeallocator&quot; to delete the pointer
            struct ScopedPointerCustomDeleter2
            {
                static inline void cleanup(int *pointer)
                {
                    delete pointer;
                }
            };

            // QScopedPointer using a custom deleter:
            QScopedPointer&lt;int, ScopedPointerCustomDeleter2&gt; customPointer(new int);
</code></pre>
<p>Dem Object QScopedPointer kann man ein custom Deleter übergeben, in dem fall &quot;ScopedPointerCustomDeleter2&quot; aber wo is hier nun die schnittstelle zu funktion<br />
&quot;void cleanup(int *pointer)&quot; ? Die struktur muss diese funktion enhalten dass es funkltioniert! aber wie macht der compiler das?</p>
<p>ich kenne es nur aus C#, da müsstte die struktur eine Interface implementieren, oder ich würde via Refelctions checlen ob die funktion v orhanden ist!<br />
Aber wie funktioniert das hier?</p>
<p>Danke <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="🙂"
    /> Ich sehe schon c++ ist wieder ganz neue für mich^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2428642</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2428642</guid><dc:creator><![CDATA[NullBockException]]></dc:creator><pubDate>Thu, 20 Nov 2014 06:41:04 GMT</pubDate></item><item><title><![CDATA[Reply to C++ wie wird hier die Schnittstelle definiert!? on Thu, 20 Nov 2014 06:42:14 GMT]]></title><description><![CDATA[<p>aaahhhh.. ich glaub das geht wg. dem schlüssewort static!</p>
<p>Intern sowas wie</p>
<pre><code>T::cleanup(...);
</code></pre>
<p>oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2428643</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2428643</guid><dc:creator><![CDATA[NullBockException]]></dc:creator><pubDate>Thu, 20 Nov 2014 06:42:14 GMT</pubDate></item><item><title><![CDATA[Reply to C++ wie wird hier die Schnittstelle definiert!? on Thu, 20 Nov 2014 07:12:50 GMT]]></title><description><![CDATA[<pre><code>struct ScopedPointerCustomDeleter2 {
	static inline void cleanup(int* pointer) {
		delete pointer;
	}
};

template&lt;typename T&gt;
void test(int* toDelete){
	T::cleanup(toDelete);//jo, genau wie Du schreibst
}
//toDo: test() in einen Destruktor einer Klasse ScopedDeleter oder so tun

int main() {
	int* pi=new int;
	test&lt;ScopedPointerCustomDeleter2&gt;(pi);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2428645</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2428645</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 20 Nov 2014 07:12:50 GMT</pubDate></item><item><title><![CDATA[Reply to C++ wie wird hier die Schnittstelle definiert!? on Thu, 20 Nov 2014 15:09:49 GMT]]></title><description><![CDATA[<p>Das inline keyword ist in diesem Fall uebrigens unnoetig und stoert den Lesefluss unnoetigerweise.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2428737</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2428737</guid><dc:creator><![CDATA[Marthog]]></dc:creator><pubDate>Thu, 20 Nov 2014 15:09:49 GMT</pubDate></item></channel></rss>