<?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[Abfragen immer mit if und else]]></title><description><![CDATA[<p>Hi,</p>
<p>müssen Abfragen immer über if und else laufen, oder darf man das auch ohne</p>
<pre><code class="language-cpp">int a,b,c;

// Ist das erlaubt ?
a = (b &gt; c);
// oder
a = ( *y &lt; JP.zoomYLL );

// oder immer mit if/else
if ( b &gt; c ) a = true;
else a = false;
// 
if ( *y &lt; JP.zoomYLL ) a = true;
else a = false;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/240581/abfragen-immer-mit-if-und-else</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 22:14:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/240581.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 08 May 2009 13:01:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Abfragen immer mit if und else on Fri, 08 May 2009 13:01:59 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>müssen Abfragen immer über if und else laufen, oder darf man das auch ohne</p>
<pre><code class="language-cpp">int a,b,c;

// Ist das erlaubt ?
a = (b &gt; c);
// oder
a = ( *y &lt; JP.zoomYLL );

// oder immer mit if/else
if ( b &gt; c ) a = true;
else a = false;
// 
if ( *y &lt; JP.zoomYLL ) a = true;
else a = false;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1707758</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1707758</guid><dc:creator><![CDATA[C++ Learner]]></dc:creator><pubDate>Fri, 08 May 2009 13:01:59 GMT</pubDate></item><item><title><![CDATA[Reply to Abfragen immer mit if und else on Fri, 08 May 2009 13:03:53 GMT]]></title><description><![CDATA[<p>Mann kann das Resultat eines Vergleichs auch in einer boolschen Variable speichern, das ist kein Problem. Hättest du aber auch einfach probieren können.</p>
<p>Die Vergleichsoperatoren sind nichts anderes als Funktionsaufrufe, welche einen <code>bool</code> zurückgeben.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1707760</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1707760</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Fri, 08 May 2009 13:03:53 GMT</pubDate></item><item><title><![CDATA[Reply to Abfragen immer mit if und else on Fri, 08 May 2009 13:23:26 GMT]]></title><description><![CDATA[<p>Hi Dravere,</p>
<p>dass das so funktioniert habe ich schon ausprobiert, meine Frage war mehr in die Richtung ob das erlaubt ist bzw. schlechter Programmierstil ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1707778</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1707778</guid><dc:creator><![CDATA[C++ Learner]]></dc:creator><pubDate>Fri, 08 May 2009 13:23:26 GMT</pubDate></item><item><title><![CDATA[Reply to Abfragen immer mit if und else on Fri, 08 May 2009 13:28:11 GMT]]></title><description><![CDATA[<p>ich wüsste nich wieso das schlechter stil sein soll<br />
Wenn du eine Funktion schreibst wie zB</p>
<pre><code class="language-cpp">bool is_greater(const T&amp; a, const T&amp; b){ return a&gt;b; }
</code></pre>
<p>nutzt du genau das selbe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1707782</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1707782</guid><dc:creator><![CDATA[nöö]]></dc:creator><pubDate>Fri, 08 May 2009 13:28:11 GMT</pubDate></item><item><title><![CDATA[Reply to Abfragen immer mit if und else on Fri, 08 May 2009 13:31:06 GMT]]></title><description><![CDATA[<p>C++ Learner schrieb:</p>
<blockquote>
<p>dass das so funktioniert habe ich schon ausprobiert, meine Frage war mehr in die Richtung ob das erlaubt ist bzw. schlechter Programmierstil ist.</p>
</blockquote>
<p>Schlechter Stil? Nein. Das mache ich oft in GUIs zum Beispiel:</p>
<pre><code class="language-cpp">bool isEnabled = selection &gt;= 0 &amp;&amp; selection &lt; list.count();

m_butA-&gt;enable(isEnabled);
m_butB-&gt;enable(isEnabled);
m_butC-&gt;enable(isEnabled);
</code></pre>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1707785</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1707785</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Fri, 08 May 2009 13:31:06 GMT</pubDate></item><item><title><![CDATA[Reply to Abfragen immer mit if und else on Fri, 08 May 2009 13:47:59 GMT]]></title><description><![CDATA[<p>C++ Learner schrieb:</p>
<blockquote>
<p>meine Frage war mehr in die Richtung ob das erlaubt ist bzw. schlechter Programmierstil ist.</p>
</blockquote>
<pre><code class="language-cpp">int a, b, c;
[...]
a = (b &gt; c);
</code></pre>
<p>ob '<strong>int</strong> a' hier das gelbe vom Ei ist, darüber kann man schon diskutieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1707795</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1707795</guid><dc:creator><![CDATA[u_ser-l]]></dc:creator><pubDate>Fri, 08 May 2009 13:47:59 GMT</pubDate></item><item><title><![CDATA[Reply to Abfragen immer mit if und else on Fri, 08 May 2009 14:13:52 GMT]]></title><description><![CDATA[<p>C++ Learner schrieb:</p>
<blockquote>
<p>schlechter Programmierstil ist.</p>
</blockquote>
<p>Das ist sogar guter Programmierstil.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1707814</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1707814</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Fri, 08 May 2009 14:13:52 GMT</pubDate></item><item><title><![CDATA[Reply to Abfragen immer mit if und else on Fri, 08 May 2009 15:46:17 GMT]]></title><description><![CDATA[<p>Bashar schrieb:</p>
<blockquote>
<p>Das ist sogar guter Programmierstil.</p>
</blockquote>
<p>Finde ich auch.</p>
<pre><code class="language-cpp">a = (b &gt; c);
</code></pre>
<p>ist für mich nicht weniger übersichtlich als</p>
<pre><code class="language-cpp">if (b &gt; c) a = true; 
else a = false;
</code></pre>
<p>wobei ich die zweite Variante so nie verwende. Abgesehen von der Redundanz gefallen mir auch die Einzeiler nicht, das finde ich eher wieder unübersichtlicher.</p>
<p>In gewissen Kontexten kannst du auch den <code>operator?:</code> anstelle von <code>if</code> -Abfragen einsetzen; zum Beispiel, wenn eine Bedingung gleich in einem grösseren Ausdruck geprüft werden soll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1707846</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1707846</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 08 May 2009 15:46:17 GMT</pubDate></item></channel></rss>