<?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[Kann man mit C++ Funktionen Verschachteln?]]></title><description><![CDATA[<p>Hallo!<br />
Habe folgendes Problem:<br />
Ich soll mittels simpson-Regel die Näherung eines Integral optional von 2 Funktionen f1 und f2 mit beliebigen Grenwerten bestimmen. f1 und f2 soll ich mit pointern in die Simpson Fkt einbringen.<br />
Folgendes habe programmiert:<br />
#include &lt;iostream&gt;<br />
#include &lt;cmath&gt;</p>
<p>using namespace std;<br />
int i;<br />
double x=0, n, a, b, h= ( b-a )/ (2*n), *f, ;</p>
<p>/*<br />
i ist Laufindex<br />
a obere Grenze, b untere Grenze<br />
h und n in Simpson verwendet</p>
<p>double f1 (double &amp;x)<br />
{<br />
double y;<br />
y=( exp(x) + 1/ exp(x) )/2 * cos(x);<br />
return y;<br />
}</p>
<p>double f2 (double &amp;x)<br />
{<br />
double y;<br />
y= 4 / ( 1+ x*x );<br />
return y;<br />
}</p>
<p>double simpson(a, b, n)<br />
{<br />
double S1=0, S2=0, I, ha, hb;<br />
for ( i=3; i&lt;= (n-2) /2; i=i+2)<br />
{<br />
x=a+i*h;<br />
S1= S1 + f;<br />
}</p>
<p>for ( i=2; i&lt; (n-1) /2 +1; i=i+2)<br />
{<br />
x= a+ i*h;<br />
S2=S2+ f;<br />
}<br />
x=a;<br />
ha = f ;<br />
x=b;<br />
hb= f ;</p>
<p>I= h/3 * ( ha + hb + 4* S1 + 2* S2);<br />
return I;<br />
}</p>
<p>Doch so lässt sich das ganze nich kompilieren. Weiß nichtmehr weiter...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/150472/kann-man-mit-c-funktionen-verschachteln</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 16:10:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/150472.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Jun 2006 21:14:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Kann man mit C++ Funktionen Verschachteln? on Fri, 16 Jun 2006 21:14:20 GMT]]></title><description><![CDATA[<p>Hallo!<br />
Habe folgendes Problem:<br />
Ich soll mittels simpson-Regel die Näherung eines Integral optional von 2 Funktionen f1 und f2 mit beliebigen Grenwerten bestimmen. f1 und f2 soll ich mit pointern in die Simpson Fkt einbringen.<br />
Folgendes habe programmiert:<br />
#include &lt;iostream&gt;<br />
#include &lt;cmath&gt;</p>
<p>using namespace std;<br />
int i;<br />
double x=0, n, a, b, h= ( b-a )/ (2*n), *f, ;</p>
<p>/*<br />
i ist Laufindex<br />
a obere Grenze, b untere Grenze<br />
h und n in Simpson verwendet</p>
<p>double f1 (double &amp;x)<br />
{<br />
double y;<br />
y=( exp(x) + 1/ exp(x) )/2 * cos(x);<br />
return y;<br />
}</p>
<p>double f2 (double &amp;x)<br />
{<br />
double y;<br />
y= 4 / ( 1+ x*x );<br />
return y;<br />
}</p>
<p>double simpson(a, b, n)<br />
{<br />
double S1=0, S2=0, I, ha, hb;<br />
for ( i=3; i&lt;= (n-2) /2; i=i+2)<br />
{<br />
x=a+i*h;<br />
S1= S1 + f;<br />
}</p>
<p>for ( i=2; i&lt; (n-1) /2 +1; i=i+2)<br />
{<br />
x= a+ i*h;<br />
S2=S2+ f;<br />
}<br />
x=a;<br />
ha = f ;<br />
x=b;<br />
hb= f ;</p>
<p>I= h/3 * ( ha + hb + 4* S1 + 2* S2);<br />
return I;<br />
}</p>
<p>Doch so lässt sich das ganze nich kompilieren. Weiß nichtmehr weiter...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1079182</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1079182</guid><dc:creator><![CDATA[Susa85]]></dc:creator><pubDate>Fri, 16 Jun 2006 21:14:20 GMT</pubDate></item><item><title><![CDATA[Reply to Kann man mit C++ Funktionen Verschachteln? on Fri, 16 Jun 2006 22:10:59 GMT]]></title><description><![CDATA[<p>N' Abend erstmal,</p>
<p>Also erstmal würde ich dir Code-TAGS für deine weiteren Posts empfehlen, dann werden die nämlich schneller beantwortet, da übersichtlicher!</p>
<p>Dann ist mir bei deinem Code aufgefallen, das er sehr viele Fehler enthält -das sind Grundlagen- ... mal ein Beispiel:</p>
<pre><code class="language-cpp">int i;
double x=0, n, a, b, h= ( b-a )/ (2*n), *f, ;
</code></pre>
<p>Das /\ könnte in etwa so (richtig!) heißen (ich weiß ja nicht was du vor hast <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> ):</p>
<pre><code class="language-cpp">int i;
double x = 0, n, a, b, h, *f;
// Initialisierungen:
a = ...;
n = ...;
// ...
h = (b - a) / (2 * n); // (2 * n) darf nie 0 werden!
</code></pre>
<p>Sry, aber du solltest dich erstmal mit den Grundlagen von C++ beschäftigen, glaube das hat sonst kein Sinn <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="🙄"
    /> (Bitte nicht böse sein... <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>Dann machst du einen zeilenübergreifenden Kommentar auf, den du nicht mehr schließt ... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
<p>Hier:</p>
<pre><code class="language-cpp">/*
i ist Laufindex
a obere Grenze, b untere Grenze
h und n in Simpson verwendet
</code></pre>
<p>Dann vllt. noch etwas zum Titel deines Posts:</p>
<p>Man kann Funktionen nicht ineinander definieren...<br />
Also so etwas geht nicht:</p>
<pre><code>void func_erstens(void)
{
   // ...
   void func_drinnen(void)
   {
      // ...
      // ...
      // ...
   }
   // ...
}
</code></pre>
<p>Du kannst sie aber in einer aufrufen, musst ggf. einen Prototypen der Funktion voranstellen, falls diese vorher nicht definiert wurde.</p>
<p>Hoffe ich konnte helfen... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1079190</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1079190</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Fri, 16 Jun 2006 22:10:59 GMT</pubDate></item></channel></rss>