<?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[Nichtgesetzte Variablen kennzeichnen]]></title><description><![CDATA[<p>Hi,<br />
ich habe ein Programmierproblem auf das ich jetzt schon öfter gestossen bin.</p>
<p>Mein Programm sieht etwa so aus:</p>
<pre><code class="language-cpp">double x1,x2;
functionxy(double a, &amp;x1, &amp;x2)
{
if(a &gt; 0)
{
x1 = a;
x2 = a;
}
else
{
x1 = a;
}
}
</code></pre>
<p>Es kann also sein, dass es nur eine Lösung gibt. x2 wird also nicht benötigt. Ich würde nur gern wissen, ob x1 UND x2 gesetzt sind oder ob nur eine Variable einen Wert besitzt. Unter php gibt es die nette Funktion isset(). Diese prüft genau das ab. Unter C++ könnte ich x2 natürlich einen DummyWert geben und schauen ob dieser gesetzt ist. Nur was wenn ich keinen Wert ausschliessen kann? Soll ich dann auf gut Glück irgendein seltsamen Wert nehmen?</p>
<p>Wie macht ihr das? Oder programmiert ihr sowas ganz anders?</p>
<p>Mfg Mo3bius</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/278477/nichtgesetzte-variablen-kennzeichnen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 25 Aug 2026 06:21:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/278477.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 Dec 2010 14:20:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Nichtgesetzte Variablen kennzeichnen on Tue, 07 Dec 2010 14:20:54 GMT]]></title><description><![CDATA[<p>Hi,<br />
ich habe ein Programmierproblem auf das ich jetzt schon öfter gestossen bin.</p>
<p>Mein Programm sieht etwa so aus:</p>
<pre><code class="language-cpp">double x1,x2;
functionxy(double a, &amp;x1, &amp;x2)
{
if(a &gt; 0)
{
x1 = a;
x2 = a;
}
else
{
x1 = a;
}
}
</code></pre>
<p>Es kann also sein, dass es nur eine Lösung gibt. x2 wird also nicht benötigt. Ich würde nur gern wissen, ob x1 UND x2 gesetzt sind oder ob nur eine Variable einen Wert besitzt. Unter php gibt es die nette Funktion isset(). Diese prüft genau das ab. Unter C++ könnte ich x2 natürlich einen DummyWert geben und schauen ob dieser gesetzt ist. Nur was wenn ich keinen Wert ausschliessen kann? Soll ich dann auf gut Glück irgendein seltsamen Wert nehmen?</p>
<p>Wie macht ihr das? Oder programmiert ihr sowas ganz anders?</p>
<p>Mfg Mo3bius</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1991057</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1991057</guid><dc:creator><![CDATA[Mo3bius]]></dc:creator><pubDate>Tue, 07 Dec 2010 14:20:54 GMT</pubDate></item><item><title><![CDATA[Reply to Nichtgesetzte Variablen kennzeichnen on Tue, 07 Dec 2010 14:23:46 GMT]]></title><description><![CDATA[<p>Mo3bius schrieb:</p>
<blockquote>
<pre><code class="language-cpp">double x1,x2;
functionxy(double a, &amp;x1, &amp;x2)
</code></pre>
</blockquote>
<pre><code class="language-cpp">functionxy(double a, double &amp;x1, bool &amp;x1set, double &amp;x2, bool &amp;x2set)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1991060</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1991060</guid><dc:creator><![CDATA[SG1]]></dc:creator><pubDate>Tue, 07 Dec 2010 14:23:46 GMT</pubDate></item><item><title><![CDATA[Reply to Nichtgesetzte Variablen kennzeichnen on Tue, 07 Dec 2010 14:24:01 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">int test = x2;

// ...

if (test != x2)
{
     // wert wurde geändert
}
</code></pre>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1991061</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1991061</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Tue, 07 Dec 2010 14:24:01 GMT</pubDate></item><item><title><![CDATA[Reply to Nichtgesetzte Variablen kennzeichnen on Tue, 07 Dec 2010 14:24:13 GMT]]></title><description><![CDATA[<p>Wie wäre es mit einem Rückgabewert der Funktion?</p>
<pre><code class="language-cpp">bool functionxy(double a, &amp;x1, &amp;x2)
{
if(a &gt; 0)
{
x1 = a;
x2 = a;

return true;
}
else
{
x1 = a;

return false;
}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1991062</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1991062</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Tue, 07 Dec 2010 14:24:13 GMT</pubDate></item><item><title><![CDATA[Reply to Nichtgesetzte Variablen kennzeichnen on Tue, 07 Dec 2010 14:24:18 GMT]]></title><description><![CDATA[<p>Mo3bius schrieb:</p>
<blockquote>
<p>Oder programmiert ihr sowas ganz anders?</p>
</blockquote>
<p>Dies. Sag mal, was das Programm überhaupt machen soll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1991063</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1991063</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 07 Dec 2010 14:24:18 GMT</pubDate></item><item><title><![CDATA[Reply to Nichtgesetzte Variablen kennzeichnen on Tue, 07 Dec 2010 14:27:22 GMT]]></title><description><![CDATA[<p>Auch nicht wahnsinnig schön aber ganz einfach z.B.:</p>
<pre><code class="language-cpp">double x1,x2;
int functionxy(double a, &amp;x1, &amp;x2)
{
if(a &gt; 0)
{
  x1 = a;
  x2 = a;
  return 2;
}
else if (a &lt; 0)
{
  x1 = a;
  return 1;
}
else
  return 0;
}
</code></pre>
<p>Wahrscheinlich würde man es in einer konkreten Anwendung noch anders machen, kannst ja mal deinen konkreten Fall erzählen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1991066</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1991066</guid><dc:creator><![CDATA[brotbernd]]></dc:creator><pubDate>Tue, 07 Dec 2010 14:27:22 GMT</pubDate></item><item><title><![CDATA[Reply to Nichtgesetzte Variablen kennzeichnen on Tue, 07 Dec 2010 14:33:24 GMT]]></title><description><![CDATA[<p>Huch das ging aber schnell mit den Antworten. <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>SeppJ schrieb:</p>
<blockquote>
<p>Mo3bius schrieb:</p>
<blockquote>
<p>Oder programmiert ihr sowas ganz anders?</p>
</blockquote>
<p>Dies. Sag mal, was das Programm überhaupt machen soll.</p>
</blockquote>
<p>Ich schreibe ein Programm das allgemeine kubische Gleichungen löst. Dabei kann es 0,1,2 oder 3 reelle Lösungen geben.</p>
<p>Bis jetzt habe ich das etwa so gemacht:</p>
<pre><code class="language-cpp">//a*x**3 + b*x**2 + c*x + d = 0
bool solvecubicequation(double a,double b,double c,double d,double &amp;x1,double &amp;x2, double &amp;x3)
{
...
}
</code></pre>
<p>Ich muss sagen die Lösung von BrotBernd gefällt mir noch am besten. Da müsste ich den Rückgabewert von bool nur nach int ändern und jeweils das rihtig returnen.</p>
<p>Mfg Mo3bius</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1991067</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1991067</guid><dc:creator><![CDATA[Mo3bius]]></dc:creator><pubDate>Tue, 07 Dec 2010 14:33:24 GMT</pubDate></item><item><title><![CDATA[Reply to Nichtgesetzte Variablen kennzeichnen on Tue, 07 Dec 2010 14:56:01 GMT]]></title><description><![CDATA[<p>Boost hat eine Klasse <a href="http://www.boost.org/doc/libs/1_45_0/libs/optional/doc/html/index.html" rel="nofollow">boost::optional</a>, die du dir womöglich mal genauer ansehen willst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1991086</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1991086</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Tue, 07 Dec 2010 14:56:01 GMT</pubDate></item><item><title><![CDATA[Reply to Nichtgesetzte Variablen kennzeichnen on Tue, 07 Dec 2010 14:56:25 GMT]]></title><description><![CDATA[<p>Wie wäre es, du gibst eine Liste der Lösungen zurück?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1991087</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1991087</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 07 Dec 2010 14:56:25 GMT</pubDate></item></channel></rss>