<?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[&amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen]]></title><description><![CDATA[<p>Hallo Zusammen!<br />
Ich wollte mal fragen an welcher Position im Quelltext bzw. Header eine typedef-Definition geschehen sollte. Sollte sie z.B. immer vor der main geschehen. Oder sollte sie bei mehreren Projektdateien immer in der Header stehen? Gibt es da eine Art Konvention?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/309208/quot-richtige-quot-positionierung-von-typedef-definitionen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 05 Aug 2026 12:09:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/309208.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 17 Oct 2012 10:16:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 10:16:22 GMT]]></title><description><![CDATA[<p>Hallo Zusammen!<br />
Ich wollte mal fragen an welcher Position im Quelltext bzw. Header eine typedef-Definition geschehen sollte. Sollte sie z.B. immer vor der main geschehen. Oder sollte sie bei mehreren Projektdateien immer in der Header stehen? Gibt es da eine Art Konvention?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261255</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261255</guid><dc:creator><![CDATA[Zero07]]></dc:creator><pubDate>Wed, 17 Oct 2012 10:16:22 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 10:21:07 GMT]]></title><description><![CDATA[<p>Ich würde jetzt mal sagen, da wo es auch hingehört, aber ich schätze das hilft dir nur bedingt, oder? Das was zusammengehört, sollte auch zusammen stehen und ein typedef hat bestimmt doch auch einen Sinn und gehört mit &quot;jemandem&quot; zusammen. Bei dem &quot;jemanden&quot; sollte dann auch das typedef stehen.</p>
<p>Am besten gibst du uns dein Beispiel und wir erklären dir, wo und wieso es dort stehen muss.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261260</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261260</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 17 Oct 2012 10:21:07 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 10:26:18 GMT]]></title><description><![CDATA[<p>Kleines Beispiel:<br />
typedef vector&lt;int&gt;::iterator VEC_IT</p>
<p>Ich möchte nun bestimmte Iteratoren definieren um diese in Schleifen zu benutzen. Sollte ich jetzt die typedef-Definition z.B. in der Header nach den includes und vor irgendwelchen Klassen machen oder macht es mehr Sinn die typedef-Definition direkt vor den angesprochenen Schleifen aufzuführen. Wie gesagt simples Beispiel!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261263</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261263</guid><dc:creator><![CDATA[Zero07]]></dc:creator><pubDate>Wed, 17 Oct 2012 10:26:18 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 10:36:43 GMT]]></title><description><![CDATA[<p>Du kannst es vieeeeeelll schöner im Schleifen-Fall machen, wenn du das Schlüsselwort auto benutzt:</p>
<pre><code class="language-cpp">for(auto it = vec.begin(); ...)
</code></pre>
<p>Wenn du aber dennoch auch typedef bestehst, dann mache es vor der Schleife. Wenn du es aber öfters benutzt, also durchgehend auch an anderen Stellen, dann hängt das wiederum vom Design ab, wo es hingehört. Aber ich empfehle dir, benutze in diesen Schleifen-Fällen nur noch auto (<a href="http://www.c-plusplus.net/forum/p2251480#2251480" rel="nofollow">http://www.c-plusplus.net/forum/p2251480#2251480</a>).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261269</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261269</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 17 Oct 2012 10:36:43 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 10:48:01 GMT]]></title><description><![CDATA[<p>Das hört sich tatsächlich einfacher an. Allerdings kannte ich es bisher nur in dem Zusammenhang:</p>
<pre><code class="language-cpp">auto int bsp;
</code></pre>
<p>Aber das ist ja gleichbedeutend mit</p>
<pre><code class="language-cpp">int bsp;
</code></pre>
<p>Handelt sich bei deinem Beispiel und meinem</p>
<pre><code class="language-cpp">auto
</code></pre>
<p>um dasselbe oder hat es bei dir einen anderen Zusammenhang?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261282</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261282</guid><dc:creator><![CDATA[Zero07]]></dc:creator><pubDate>Wed, 17 Oct 2012 10:48:01 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 11:03:47 GMT]]></title><description><![CDATA[<p>Die Bedeutung von auto wurde mit C++11 geaendert. Ersteres ist nicht mehr gueltig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261294</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261294</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Wed, 17 Oct 2012 11:03:47 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 11:21:28 GMT]]></title><description><![CDATA[<p>Google mal nach &quot;C++11 auto&quot;. Hier ne kurze Einführung: <a href="http://www.stroustrup.com/C++11FAQ.html#auto" rel="nofollow">http://www.stroustrup.com/C++11FAQ.html#auto</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261304</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261304</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 17 Oct 2012 11:21:28 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 11:34:49 GMT]]></title><description><![CDATA[<p>Das heißt ich hab folgendes Beispiel:</p>
<p>Ich möchte z.B. eine print-Funktion schreiben.</p>
<pre><code class="language-cpp">class Map {
private:
   map&lt;int, vector&lt;int&gt; &gt; myMap;
   //usw...

public:
    void printMap() const {
         for(auto map_it = myMap.begin();map_it != myMap.end();map_it++) {
              cout &lt;&lt; (*map_it).first &lt;&lt; &quot;: &quot;;
              for(auto vec_it = (*map_it).second.begin();vec_it &lt; (*map_it).second.end();vec_it++) {
                  cout &lt;&lt; *vec_it &lt;&lt; &quot; &quot;;
              }
         }
    }
    //usw....
}
</code></pre>
<p>Wäre es dann so sinnvoll?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261306</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261306</guid><dc:creator><![CDATA[Zero07]]></dc:creator><pubDate>Wed, 17 Oct 2012 11:34:49 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 11:30:09 GMT]]></title><description><![CDATA[<p>auto? Ja. Ne globale Variable statt einem Parameter? Nein. (Aber das const sieht so aus, als wäre es aus einer Klasse kopiert.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261309</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261309</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Wed, 17 Oct 2012 11:30:09 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 11:32:13 GMT]]></title><description><![CDATA[<p>Ja. Weist du, ob dein Compiler überhaupt C++11 Features unterstützt?</p>
<p>Ein paar Code-Kleinigkeiten:<br />
- Du könntest statt (*x).y auch x-&gt;y benutzen<br />
- Bei der vector-Schleife auch in der Bedingung bitte != benutzen<br />
- Dir vielleicht angewöhnen ++it statt it++ zu schreiben<br />
- Seit C++11 kannst du auch die spitzen Klammern zusammen schreiben:</p>
<pre><code class="language-cpp">map&lt;int, vector&lt;int&gt;&gt; myMap;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2261310</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261310</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 17 Oct 2012 11:32:13 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 11:33:20 GMT]]></title><description><![CDATA[<p>cooky451 schrieb:</p>
<blockquote>
<p>Ne globale Variable statt einem Parameter?</p>
</blockquote>
<p>Ich hatte eher das Gefühl, das steht da nur, um uns zu zeigen was myMap überhaupt ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261311</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261311</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 17 Oct 2012 11:33:20 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 11:39:37 GMT]]></title><description><![CDATA[<p>Ja so war es gemeint, aber hab es eh editiert.<br />
Ok danke;) Ja unterstützt er.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261313</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261313</guid><dc:creator><![CDATA[Zero07]]></dc:creator><pubDate>Wed, 17 Oct 2012 11:39:37 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 16:20:37 GMT]]></title><description><![CDATA[<p>KasF schrieb:</p>
<blockquote>
<p>- Dir vielleicht angewöhnen ++it statt it++ zu schreiben</p>
</blockquote>
<p>Ist es in der Schleife nicht egal ob ich ++it oder it++ schreibe?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261416</guid><dc:creator><![CDATA[Zero07]]></dc:creator><pubDate>Wed, 17 Oct 2012 16:20:37 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 16:27:57 GMT]]></title><description><![CDATA[<p>Zero07 schrieb:</p>
<blockquote>
<p>Ist es in der Schleife nicht egal ob ich ++it oder it++ schreibe?!</p>
</blockquote>
<p>VOm Ergebnis her ja, von der Performance her nicht.</p>
<p>it++ erhöht ja den Iterator und gibt den Iterator zurück, wie er <em>vor</em> der Erhöhung war. Auch wenn du den Rückgabewert nicht benutzt, muss dafür eine Kopie angelegt werden, die hinterher zurückgegeben werden kann - und nicht benutzt wird, also völlig unnötig ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261418</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261418</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Wed, 17 Oct 2012 16:27:57 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Wed, 17 Oct 2012 17:47:05 GMT]]></title><description><![CDATA[<p>Noch ein klein wenig ausführlicher:</p>
<pre><code class="language-cpp">int a = 0;
int b = a++; // b ist nun 0 und a auf 1

int c = 0;
int d = ++d; // d ist nun 1 und c ebenfalls
</code></pre>
<p>Der Postinkrement-Operator (x++) gibt den aktuellen Wert von x zurück und inkrementiert danach. Der Preinkrement-Operator (++x) inkrementiert x und gibt den inkrementierten Wert zurück. Wenn du den Operator mal für deine Klasse selbst implementieren solltest, dann sieht das so aus:</p>
<pre><code class="language-cpp">MyClass&amp; operator++() // Preinkrement
{
    this.irgendwas erhöhen
    return *this;
}

MyClass operator++(int) // Postinkrement
{
    MyClass temp = *this;
    ++(*this); // über preinkrment erhöhen
    return temp; // alten Wert zurückgeben
}
</code></pre>
<p>Du siehst, in ++(int) steht ein bissl mehr, was auch ein bissl mehr dann kostet. Ich schaetze aber ehe, dass dein Compiler das in den meisten Faellen richtig optimiert. Trotzdem willst du ja in deinem Beispiel nur das it erhöhen. Das es dir aber mit dem Postinkrement eine weitere Funktionalitaet zur Verfügung stellt, interessiert ja nicht. Wieso für etwas zahlen, wenn man es nicht benutzt. Auch wenn das PODs (<a href="http://www.c-plusplus.net/forum/194356" rel="nofollow">FAQ</a>) keine Rolle spielt, gewöhne es dir an.</p>
<p>PS: Irgendwie sieht das Wort Pre-/Postinkrement komisch aus <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2261458</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261458</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 17 Oct 2012 17:47:05 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Richtige&amp;quot; Positionierung von typedef-Definitionen on Thu, 18 Oct 2012 07:49:01 GMT]]></title><description><![CDATA[<p>Es leuchtet mir ein <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/2261558</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2261558</guid><dc:creator><![CDATA[Zero07]]></dc:creator><pubDate>Thu, 18 Oct 2012 07:49:01 GMT</pubDate></item></channel></rss>