<?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[Multiple Rückgabe&#x2F;Derefferenzieren]]></title><description><![CDATA[<p>Moinsen,</p>
<p>ich beschäftige mich gerade mit C++ und habe eine Funktion, die mehrere Rückgaben haben soll. Das ganze passiert mit dem Aufruf</p>
<pre><code>calcPos(dt, nx, ny, nBeam, nDeg, &amp;sPos, &amp;dPos);
</code></pre>
<p>dt, sind unputdaten, nx, ny, nBeam und nDeg konstanten (int) und sPos bzw dPos sollen rauskommen (double mit Sternchen).<br />
Leider bekomme ich es nicht, dass ich nach dem Funktionsaufruf auch die selben Daten zur Verfügung habe, wie innerhalb der Funktion calcPos. Wie bekommt man sowas am besten gelöst? Ich würde danach gerne auf einzelne Elemente aus sPos und dPos zugreifen, um damit weiterzuarbeiten.</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/321277/multiple-rückgabe-derefferenzieren</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 18:24:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/321277.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 30 Oct 2013 16:21:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Multiple Rückgabe&#x2F;Derefferenzieren on Wed, 30 Oct 2013 16:21:25 GMT]]></title><description><![CDATA[<p>Moinsen,</p>
<p>ich beschäftige mich gerade mit C++ und habe eine Funktion, die mehrere Rückgaben haben soll. Das ganze passiert mit dem Aufruf</p>
<pre><code>calcPos(dt, nx, ny, nBeam, nDeg, &amp;sPos, &amp;dPos);
</code></pre>
<p>dt, sind unputdaten, nx, ny, nBeam und nDeg konstanten (int) und sPos bzw dPos sollen rauskommen (double mit Sternchen).<br />
Leider bekomme ich es nicht, dass ich nach dem Funktionsaufruf auch die selben Daten zur Verfügung habe, wie innerhalb der Funktion calcPos. Wie bekommt man sowas am besten gelöst? Ich würde danach gerne auf einzelne Elemente aus sPos und dPos zugreifen, um damit weiterzuarbeiten.</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363922</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363922</guid><dc:creator><![CDATA[JonnyTJay]]></dc:creator><pubDate>Wed, 30 Oct 2013 16:21:25 GMT</pubDate></item><item><title><![CDATA[Reply to Multiple Rückgabe&#x2F;Derefferenzieren on Wed, 30 Oct 2013 16:27:26 GMT]]></title><description><![CDATA[<p>Gibt doch bitte mal die Signatur von <code>calcPos</code> an! Wie wird das Array <code>sPos</code> / <code>dPos</code> erzeugt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363924</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363924</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Wed, 30 Oct 2013 16:27:26 GMT</pubDate></item><item><title><![CDATA[Reply to Multiple Rückgabe&#x2F;Derefferenzieren on Wed, 30 Oct 2013 16:31:50 GMT]]></title><description><![CDATA[<p>Signatur aus dem h-file:</p>
<pre><code>void calcPos(double* image, int nx, int ny, int nBeam, int nDeg, double* sourceP, double* detectorP);
</code></pre>
<p>Bisher:</p>
<pre><code>double sPos; double dPos;
</code></pre>
<p>da ich nicht weiss, wie man das geschickter macht. Ich dachte man kann den Inhalt von sPos bzw sourceP nach dem Funktionsaufruf irgendwie casten, das klappt aber nicht.<br />
Was ich machen möchte ist, dass ein Array beschrieben wird. Habe aber leider nicht genug Erfahrung (wie mir scheint), um mit den Sternchen und dem Derefferenzieren vernünftig umzugehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363925</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363925</guid><dc:creator><![CDATA[JonnyTJay]]></dc:creator><pubDate>Wed, 30 Oct 2013 16:31:50 GMT</pubDate></item><item><title><![CDATA[Reply to Multiple Rückgabe&#x2F;Derefferenzieren on Wed, 30 Oct 2013 16:51:29 GMT]]></title><description><![CDATA[<p>EDIT: Hab nicht richtig gelesen</p>
<p>Bin Anfang und weiß nicht genau was du meist.</p>
<p>Hier ein Beispiel.Vllt hilf es dir:</p>
<pre><code>#include &lt;iostream&gt;

using namespace std;

void calcPos(int a, int* sPos, int* dPos);

int main(){

	int a[2] = {5,4};
	int b[2] = {10,8};

	calcPos(10,a ,b);

	cout &lt;&lt; a[0] &lt;&lt; &quot; &quot; &lt;&lt; a[1] &lt;&lt; &quot; &quot; &lt;&lt; b[0] &lt;&lt; &quot; &quot; &lt;&lt; b[1] &lt;&lt; endl;

	cin.get();
	return 0;
}

void calcPos(int a, int* sPos, int* dPos){
	sPos[0] += 1;
	sPos[1] += 2;

	dPos[0] += 1;
	dPos[1] += 2;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2363928</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363928</guid><dc:creator><![CDATA[CraftPlorer]]></dc:creator><pubDate>Wed, 30 Oct 2013 16:51:29 GMT</pubDate></item><item><title><![CDATA[Reply to Multiple Rückgabe&#x2F;Derefferenzieren on Wed, 30 Oct 2013 16:43:20 GMT]]></title><description><![CDATA[<p>Die Funktion calcPos arbeitet intern mit Indizes, das geht mit Referenzen scheinbar nicht (Compilern fängt an zu weinen).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363931</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363931</guid><dc:creator><![CDATA[JonnyTJay]]></dc:creator><pubDate>Wed, 30 Oct 2013 16:43:20 GMT</pubDate></item><item><title><![CDATA[Reply to Multiple Rückgabe&#x2F;Derefferenzieren on Wed, 30 Oct 2013 16:50:12 GMT]]></title><description><![CDATA[<p>JonnyTJay schrieb:</p>
<blockquote>
<p>Bisher:</p>
<pre><code>double sPos; double dPos;
</code></pre>
</blockquote>
<p>Wie soll darauf mit einem Index zugegriffen werden? Das sind keine Arrays.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363936</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363936</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Wed, 30 Oct 2013 16:50:12 GMT</pubDate></item><item><title><![CDATA[Reply to Multiple Rückgabe&#x2F;Derefferenzieren on Wed, 30 Oct 2013 16:52:32 GMT]]></title><description><![CDATA[<blockquote>
<p>Was ich machen möchte ist, dass ein Array beschrieben wird</p>
</blockquote>
<p>Dazu musst du ein Array erzeugen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363937</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363937</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Wed, 30 Oct 2013 16:52:32 GMT</pubDate></item><item><title><![CDATA[Reply to Multiple Rückgabe&#x2F;Derefferenzieren on Wed, 30 Oct 2013 16:57:43 GMT]]></title><description><![CDATA[<p>Ist ja ein Teil meines Problems.</p>
<p>Hmpf, ich dachte bisher, wenn ich ein pointer übergebe, bekomme ich am Ende nichts zurück, weil der Speicher woanders allokiert wird.</p>
<p>Ist es nun richtig, dass wenn ich er den Speicher mit</p>
<pre><code>double* ssPos = (double *)malloc(2*nDeg*nBeam*sizeof(double));
	double* ddPos = (double *)malloc(2*nDeg*nBeam*sizeof(double));
</code></pre>
<p>allokiere und dann den Aufruf per</p>
<pre><code>calcPos(dt, nx, ny, nBeam, nDeg, ssPos, ddPos);
</code></pre>
<p>durchführe, all in der Funktion erzeugten Daten in ssPos und ddPos wieder &quot;rauskommen&quot;?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363939</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363939</guid><dc:creator><![CDATA[JonnyTJay]]></dc:creator><pubDate>Wed, 30 Oct 2013 16:57:43 GMT</pubDate></item><item><title><![CDATA[Reply to Multiple Rückgabe&#x2F;Derefferenzieren on Wed, 30 Oct 2013 17:03:03 GMT]]></title><description><![CDATA[<p>Ja, tun sie. Peinlich peinlich, aber wieder was gelernt <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/2363942</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363942</guid><dc:creator><![CDATA[JonnyTJay]]></dc:creator><pubDate>Wed, 30 Oct 2013 17:03:03 GMT</pubDate></item></channel></rss>