<?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[funktion als parameter uebergeben]]></title><description><![CDATA[<p>Moin</p>
<p>Der Titel sagt alles, nur wie?<br />
Ich habe mal etwas gegooglet, aber nur C styles gesehen.</p>
<p>Gibt es eine moeglichkeit mit C++ das zu machen?<br />
Danach habe ich noch was von boost::function0 gelesen,<br />
hat jemand schon erfahrung damit?<br />
Ich will am ende ein vector machen mit funktionen als elemente.</p>
<p>Das mit dem c ging irgendwie so:</p>
<pre><code class="language-cpp">void funct_geb(void){

 //...

}

void funct_brauch(void (*funct_is)){

 funct_is();

}

int main(){

 funct_brauch(&amp;funct_geb);

 return 1;

}
// kann funct_geb auch parameter haben?
</code></pre>
<p>Thx,<br />
Gg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/146248/funktion-als-parameter-uebergeben</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Sep 2026 15:32:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/146248.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 May 2006 16:31:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to funktion als parameter uebergeben on Fri, 05 May 2006 16:31:45 GMT]]></title><description><![CDATA[<p>Moin</p>
<p>Der Titel sagt alles, nur wie?<br />
Ich habe mal etwas gegooglet, aber nur C styles gesehen.</p>
<p>Gibt es eine moeglichkeit mit C++ das zu machen?<br />
Danach habe ich noch was von boost::function0 gelesen,<br />
hat jemand schon erfahrung damit?<br />
Ich will am ende ein vector machen mit funktionen als elemente.</p>
<p>Das mit dem c ging irgendwie so:</p>
<pre><code class="language-cpp">void funct_geb(void){

 //...

}

void funct_brauch(void (*funct_is)){

 funct_is();

}

int main(){

 funct_brauch(&amp;funct_geb);

 return 1;

}
// kann funct_geb auch parameter haben?
</code></pre>
<p>Thx,<br />
Gg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051660</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051660</guid><dc:creator><![CDATA[xGhost]]></dc:creator><pubDate>Fri, 05 May 2006 16:31:45 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Fri, 05 May 2006 16:46:24 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>dazu brauichst du <a href="http://tutorial.schornboeck.net/funkt_zeiger.htm" rel="nofollow">Funktionspointer</a>.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051673</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051673</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Fri, 05 May 2006 16:46:24 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Fri, 05 May 2006 17:26:17 GMT]]></title><description><![CDATA[<p><a href="http://www.boost.org/doc/html/function.html" rel="nofollow">Hier</a> ist das was du suchst. Funktionszeiger sind C, das ist C++.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051711</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051711</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Fri, 05 May 2006 17:26:17 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Fri, 05 May 2006 18:02:58 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Nein boost ist eine externe Bibliothek und gehört nicht zum aktuellen C++ Standard. Also sind Funktionspointer das einzige Mittel dafür sowohl in C als auch in C++</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051733</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051733</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Fri, 05 May 2006 18:02:58 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Fri, 05 May 2006 18:25:07 GMT]]></title><description><![CDATA[<p>Blabla. Funktionszeiger sind nunmal C. Sie funktionieren z.B. nicht mit Funktionsobjekten und Methoden, obwohl diese jawohl auch Funktionen sind. Ergo müsste man sich selbst was schreiben, da das aber bei solch elementaren Kram nicht angebracht ist (außer zur Übung) nimmt man eine fertige Implementierung. Eine andere Möglichkeit dafür wäre <a href="http://loki-lib.sourceforge.net/" rel="nofollow">Loki</a>, aber Boost ist mehr im Stil der Standardbibliothek.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051741</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051741</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Fri, 05 May 2006 18:25:07 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Fri, 05 May 2006 18:30:41 GMT]]></title><description><![CDATA[<p>.filmor schrieb:</p>
<blockquote>
<p>Sie funktionieren z.B. nicht mit Funktionsobjekten und Methoden</p>
</blockquote>
<p>BTW: Statische Methoden funktionieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051744</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051744</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Fri, 05 May 2006 18:30:41 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Fri, 05 May 2006 18:47:12 GMT]]></title><description><![CDATA[<p>.filmor schrieb:</p>
<blockquote>
<p>Blabla. Funktionszeiger sind nunmal C. Sie funktionieren z.B. nicht mit Funktionsobjekten und Methoden, obwohl diese jawohl auch Funktionen sind. Ergo müsste man sich selbst was schreiben, da das aber bei solch elementaren Kram nicht angebracht ist (außer zur Übung) nimmt man eine fertige Implementierung. Eine andere Möglichkeit dafür wäre <a href="http://loki-lib.sourceforge.net/" rel="nofollow">Loki</a>, aber Boost ist mehr im Stil der Standardbibliothek.</p>
</blockquote>
<p>Solltest vielleicht mal <a href="http://www.newty.de/fpt/index.html" rel="nofollow">http://www.newty.de/fpt/index.html</a> lesen.<br />
Kurt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051750</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051750</guid><dc:creator><![CDATA[ZuK]]></dc:creator><pubDate>Fri, 05 May 2006 18:47:12 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Fri, 05 May 2006 18:47:33 GMT]]></title><description><![CDATA[<p>.filmor schrieb:</p>
<blockquote>
<p>Blabla. Funktionszeiger sind nunmal C. Sie funktionieren z.B. nicht mit Funktionsobjekten und Methoden, obwohl diese jawohl auch Funktionen sind. Ergo müsste man sich selbst was schreiben, da das aber bei solch elementaren Kram nicht angebracht ist (außer zur Übung) nimmt man eine fertige Implementierung. Eine andere Möglichkeit dafür wäre <a href="http://loki-lib.sourceforge.net/" rel="nofollow">Loki</a>, aber Boost ist mehr im Stil der Standardbibliothek.</p>
</blockquote>
<p>Stimmt.</p>
<p>Und obwohl Boost NOCH nicht zu den std gehoert, setzte ich es ein.<br />
Boost ist gut. Filesystem oder threads oder sonst was sind<br />
OS unabhaengig, und somit spart man sich zeit.</p>
<p>Thx</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051751</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051751</guid><dc:creator><![CDATA[xGhost]]></dc:creator><pubDate>Fri, 05 May 2006 18:47:33 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Fri, 05 May 2006 18:57:06 GMT]]></title><description><![CDATA[<p>So einfach kann es gehen:<br />
<a href="http://www.boost.org/doc/html/function/tutorial.html" rel="nofollow">http://www.boost.org/doc/html/function/tutorial.html</a></p>
<p>was ist daran kein sauberer style <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/7971">@akari</a>?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051759</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051759</guid><dc:creator><![CDATA[xGhost]]></dc:creator><pubDate>Fri, 05 May 2006 18:57:06 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Fri, 05 May 2006 19:42:49 GMT]]></title><description><![CDATA[<p>Michael E. schrieb:</p>
<blockquote>
<p>.filmor schrieb:</p>
<blockquote>
<p>Sie funktionieren z.B. nicht mit Funktionsobjekten und Methoden</p>
</blockquote>
<p>BTW: Statische Methoden funktionieren.</p>
</blockquote>
<p>Definition der Wikipedia: &quot;eine definierte Aktion eines <strong>Objekts</strong>&quot;. Statische Klassenfunktionen sind danach keine Methoden.</p>
<p>ZuK schrieb:</p>
<blockquote>
<p>Solltest vielleicht mal <a href="http://www.newty.de/fpt/index.html" rel="nofollow">http://www.newty.de/fpt/index.html</a></p>
</blockquote>
<p>Hab ich, und weiter?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051774</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051774</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Fri, 05 May 2006 19:42:49 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Fri, 05 May 2006 20:11:07 GMT]]></title><description><![CDATA[<p>xGhost schrieb:</p>
<blockquote>
<p>So einfach kann es gehen:<br />
<a href="http://www.boost.org/doc/html/function/tutorial.html" rel="nofollow">http://www.boost.org/doc/html/function/tutorial.html</a></p>
<p>was ist daran kein sauberer style <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/7971">@akari</a>?</p>
</blockquote>
<p>Habe ich behauptet, das es kein sauberer Stil wäre? Ich habe nur gesagt, das Boost eine externe Lib ist und nicht im C++ Standard. Und das ist wohl nicht strittig.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051786</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051786</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Fri, 05 May 2006 20:11:07 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Sat, 06 May 2006 07:10:40 GMT]]></title><description><![CDATA[<p>.filmor schrieb:</p>
<blockquote>
<p>Michael E. schrieb:</p>
<blockquote>
<p>.filmor schrieb:</p>
<blockquote>
<p>Sie funktionieren z.B. nicht mit Funktionsobjekten und Methoden</p>
</blockquote>
<p>BTW: Statische Methoden funktionieren.</p>
</blockquote>
<p>Definition der Wikipedia: &quot;eine definierte Aktion eines <strong>Objekts</strong>&quot;. Statische Klassenfunktionen sind danach keine Methoden.</p>
</blockquote>
<p>Das ist lediglich ne Frage der Namensgebung. Für mich zum Beispiel sind es Methoden, weil man in C# nur noch von Methoden spricht und es auch dort statische Funktionen gibt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051886</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051886</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Sat, 06 May 2006 07:10:40 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Sat, 06 May 2006 09:27:21 GMT]]></title><description><![CDATA[<p>.filmor schrieb:</p>
<blockquote>
<p>Funktionszeiger sind nunmal C. Sie funktionieren z.B. nicht mit Funktionsobjekten und Methoden, obwohl diese jawohl auch Funktionen sind.</p>
</blockquote>
<p>Funktionsobjekte haben ihren eigenen Typ und können imho noch leichter übergeben werden als &quot;echte&quot; Funktionen. Und für Methoden hat C++ die Funktionszeiger-Syntax etwas erweitert (auf Methodenzeiger ala &quot;typedef int (T::*t_met)(int) - aber das sieht grausam aus).</p>
<p>In C++ nimmt man dann häufig Templates, um alles mögliche zu verarbeiten:</p>
<pre><code class="language-cpp">template&lt;typename func&gt;
double ableit(double x0,func f)
{
  //berechne f'(x0)
  //das lässt sich compilieren, solange f(y) für einen double-Wert y gültig ist
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1051930</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051930</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sat, 06 May 2006 09:27:21 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Sat, 06 May 2006 09:31:19 GMT]]></title><description><![CDATA[<p>akari schrieb:</p>
<blockquote>
<p>Nein boost ist eine externe Bibliothek und gehört nicht zum aktuellen C++ Standard. Also sind Funktionspointer das einzige Mittel dafür sowohl in C als auch in C++</p>
</blockquote>
<p>Der erste Satz ist natürlich richtig. Der zweite aber vollkommener Quatsch. boost ist doch in Standard-C++ implementiert. Also gibt es in Standard-C++ doch mehr Möglichkeiten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051931</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051931</guid><dc:creator><![CDATA[Jester]]></dc:creator><pubDate>Sat, 06 May 2006 09:31:19 GMT</pubDate></item><item><title><![CDATA[Reply to funktion als parameter uebergeben on Sat, 06 May 2006 12:47:31 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>.filmor schrieb:</p>
<blockquote>
<p>Funktionszeiger sind nunmal C. Sie funktionieren z.B. nicht mit Funktionsobjekten und Methoden, obwohl diese jawohl auch Funktionen sind.</p>
</blockquote>
<p>Funktionsobjekte haben ihren eigenen Typ und können imho noch leichter übergeben werden als &quot;echte&quot; Funktionen. Und für Methoden hat C++ die Funktionszeiger-Syntax etwas erweitert (auf Methodenzeiger ala &quot;typedef int (T::*t_met)(int) - aber das sieht grausam aus).</p>
<p>In C++ nimmt man dann häufig Templates, um alles mögliche zu verarbeiten:</p>
<pre><code class="language-cpp">template&lt;typename func&gt;
double ableit(double x0,func f)
{
  //berechne f'(x0)
  //das lässt sich compilieren, solange f(y) für einen double-Wert y gültig ist
}
</code></pre>
</blockquote>
<p>Aber der Threadsteller sprach doch davon, dass er die Funktionen in einem Vektor speichern wolle. Da Funktionsobjekte, Methodenzeiger und Funktionszeiger jeweils unterschiedlich groß sind (nämlich 1. beliebig, 2. 2*sizeof (void*) und 3. sizeof (void*) iirc), funktioniert das so nicht, man muss den Aufruf also kapseln, wofür man wiederum boost::function oder die Loki-Variante nimmt, wobei ersteres aber allgemein portabler sein sollte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1052006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1052006</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Sat, 06 May 2006 12:47:31 GMT</pubDate></item></channel></rss>