<?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[template]]></title><description><![CDATA[<p>Wenn ich diese Implementierung in template umschreiben will:</p>
<pre><code class="language-cpp">void swap ( int *a, int *b ) {
	int temp = *a;
	*a = *b;
	*b = temp;
}

void bubbleSort ( int *werte, int anzahl ) {
	int i, j;
	for ( i = anzahl-1; i &gt; 0; -i )
		for ( j = 0; j &lt; i; ++j )
			if( werte[j] &lt; werte[j+1] )
				swap( &amp;werte[j], &amp;werte[j+1] );
}
</code></pre>
<p>dann sieht das doch so aus oder ?</p>
<pre><code class="language-cpp">template&lt;class T&gt; void swap ( T *a, T *b ) {
	T temp = *a;
	*a = *b;
	*b = temp;
}

template&lt;class T&gt; void bubbleSort ( T *werte, T anzahl ) {
	T i, j;
	for ( i = anzahl-1; i &gt; 0; -i )
		for ( j = 0; j &lt; i; ++j )
			if( werte[j] &lt; werte[j+1] )
				swap( &amp;werte[j], &amp;werte[j+1] );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/260370/template</link><generator>RSS for Node</generator><lastBuildDate>Tue, 08 Sep 2026 02:28:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/260370.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Feb 2010 11:45:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 11:45:34 GMT]]></title><description><![CDATA[<p>Wenn ich diese Implementierung in template umschreiben will:</p>
<pre><code class="language-cpp">void swap ( int *a, int *b ) {
	int temp = *a;
	*a = *b;
	*b = temp;
}

void bubbleSort ( int *werte, int anzahl ) {
	int i, j;
	for ( i = anzahl-1; i &gt; 0; -i )
		for ( j = 0; j &lt; i; ++j )
			if( werte[j] &lt; werte[j+1] )
				swap( &amp;werte[j], &amp;werte[j+1] );
}
</code></pre>
<p>dann sieht das doch so aus oder ?</p>
<pre><code class="language-cpp">template&lt;class T&gt; void swap ( T *a, T *b ) {
	T temp = *a;
	*a = *b;
	*b = temp;
}

template&lt;class T&gt; void bubbleSort ( T *werte, T anzahl ) {
	T i, j;
	for ( i = anzahl-1; i &gt; 0; -i )
		for ( j = 0; j &lt; i; ++j )
			if( werte[j] &lt; werte[j+1] )
				swap( &amp;werte[j], &amp;werte[j+1] );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1850326</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850326</guid><dc:creator><![CDATA[c.groupe]]></dc:creator><pubDate>Thu, 04 Feb 2010 11:45:34 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 11:49:48 GMT]]></title><description><![CDATA[<p>Wieso sollte &quot;anzahl&quot; (und die beiden Zähler) nicht int bleiben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1850336</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850336</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Thu, 04 Feb 2010 11:49:48 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 11:50:37 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">template&lt;class T&gt; void bubbleSort ( T *werte, T anzahl ) {
	T i, j;
</code></pre>
<p>Da solltest du nochmal drüber nachdenken...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1850338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850338</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or_off]]></dc:creator><pubDate>Thu, 04 Feb 2010 11:50:37 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 13:25:41 GMT]]></title><description><![CDATA[<p>l'abra d'or_off schrieb:</p>
<blockquote>
<pre><code class="language-cpp">template&lt;class T&gt; void bubbleSort ( T *werte, T anzahl ) {
	T i, j;
</code></pre>
<p>Da solltest du nochmal drüber nachdenken...</p>
</blockquote>
<p>daher frag ich ja, ..</p>
<pre><code class="language-cpp">template&lt;class T&gt; void swap ( T *a, T *b ) {
    T temp = *a;
    *a = *b;
    *b = temp;
}

template&lt;class T&gt; void bubbleSort ( T *werte, int anzahl ) {
    int i, j;
    for ( i = anzahl-1; i &gt; 0; -i )
        for ( j = 0; j &lt; i; ++j )
            if( werte[j] &lt; werte[j+1] )
                swap( &amp;werte[j], &amp;werte[j+1] );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1850363</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850363</guid><dc:creator><![CDATA[c.groupe]]></dc:creator><pubDate>Thu, 04 Feb 2010 13:25:41 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 13:53:12 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">for(...; -i)
</code></pre>
<p>und darüber auch -)</p>
<p>P.S. Du hast keinen BubbleSort implementiert, s.a. <a href="http://de.wikipedia.org/wiki/Bubblesort" rel="nofollow">http://de.wikipedia.org/wiki/Bubblesort</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1850424</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850424</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Thu, 04 Feb 2010 13:53:12 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 13:57:14 GMT]]></title><description><![CDATA[<p>Th69 schrieb:</p>
<blockquote>
<pre><code class="language-cpp">for(...; -i)
</code></pre>
<p>und darüber auch -)</p>
<p>P.S. Du hast keinen BubbleSort implementiert, s.a. <a href="http://de.wikipedia.org/wiki/Bubblesort" rel="nofollow">http://de.wikipedia.org/wiki/Bubblesort</a></p>
</blockquote>
<p><a href="http://img692.imageshack.us/img692/6554/tempcc.jpg" rel="nofollow">http://img692.imageshack.us/img692/6554/tempcc.jpg</a></p>
<p>hab nur diese aufgabe machen wollen, nicht mehr nicht weniger,<br />
ober der code vollständig ist intressiert hier nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1850429</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850429</guid><dc:creator><![CDATA[c.groupe]]></dc:creator><pubDate>Thu, 04 Feb 2010 13:57:14 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 14:20:55 GMT]]></title><description><![CDATA[<p>Du solltest das Buch löschen, es ist kaputt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1850447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850447</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 04 Feb 2010 14:20:55 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 14:35:34 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>Du solltest das Buch löschen, es ist kaputt.</p>
</blockquote>
<p>mit andern worten, mein prof hat nichts drauf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1850459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850459</guid><dc:creator><![CDATA[c.groupe]]></dc:creator><pubDate>Thu, 04 Feb 2010 14:35:34 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 14:58:00 GMT]]></title><description><![CDATA[<p>c.groupe schrieb:</p>
<blockquote>
<p>volkard schrieb:</p>
<blockquote>
<p>Du solltest das Buch löschen, es ist kaputt.</p>
</blockquote>
<p>mit andern worten, mein prof hat nichts drauf.</p>
</blockquote>
<p>Oder du solltest dein Prof löschen ... verbrennen? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Hat sich eigentlich dein &quot;Problem&quot; erledigt?</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1850483</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850483</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Thu, 04 Feb 2010 14:58:00 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 15:00:13 GMT]]></title><description><![CDATA[<p>Das mit dem -i kommt wohl daher das beim Setzen des Textes aus dem -- ein Gedankenstrich gemacht wurde. Word macht sowas ja auch gerne wenn man nicht drauf achtet. Also bei allen solchen Stellen aufpassen, wenn du eh dazu gezwungen wirst es weiter zu benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1850485</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850485</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Thu, 04 Feb 2010 15:00:13 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 15:02:08 GMT]]></title><description><![CDATA[<p>aber wie ich das sehe sollst du auch die swap funktion anpassen</p>
<p>das heisst du musst das noch dranhängen (es sei denn du nutzt die der stl)</p>
<pre><code class="language-cpp">template&lt;typename _T&gt;
void swap(_T &amp; a, _T &amp; b)
{
    _T tmp(a);
    a = b;
    b = tmp;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1850488</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850488</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Thu, 04 Feb 2010 15:02:08 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 15:34:59 GMT]]></title><description><![CDATA[<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>aber wie ich das sehe sollst du auch die swap funktion anpassen</p>
<p>das heisst du musst das noch dranhängen (es sei denn du nutzt die der stl)</p>
<pre><code class="language-cpp">template&lt;typename _T&gt;
void swap(_T &amp; a, _T &amp; b)
{
    _T tmp(a);
    a = b;
    b = tmp;
}
</code></pre>
</blockquote>
<p>Warum der Unterstrich im Bezeichner? Der macht doch alles nur häßlich und nicht toll.<br />
Außerdem kann man's bei der Zeigerversion belassen, man will den Prof ja nicht erschrecken.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1850514</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850514</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 04 Feb 2010 15:34:59 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 15:43:53 GMT]]></title><description><![CDATA[<p>also geht das ja nun in ordnung.</p>
<pre><code class="language-cpp">template&lt;typename T&gt; void swap ( T *a, T *b ) {
    T temp = *a;
    *a = *b;
    *b = temp;
}

template&lt;class T&gt; void bubbleSort ( T *werte, int anzahl ) {
    int i, j;
    for ( i = anzahl-1; i &gt; 0; --i )
        for ( j = 0; j &lt; i; ++j )
            if( werte[j] &lt; werte[j+1] )
                swap( &amp;werte[j], &amp;werte[j+1] );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1850518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850518</guid><dc:creator><![CDATA[c.groupe]]></dc:creator><pubDate>Thu, 04 Feb 2010 15:43:53 GMT</pubDate></item><item><title><![CDATA[Reply to template on Thu, 04 Feb 2010 15:45:35 GMT]]></title><description><![CDATA[<p>Fellhuhn schrieb:</p>
<blockquote>
<p>Das mit dem -i kommt wohl daher das beim Setzen des Textes aus dem -- ein Gedankenstrich gemacht wurde. Word macht sowas ja auch gerne wenn man nicht drauf achtet. Also bei allen solchen Stellen aufpassen, wenn du eh dazu gezwungen wirst es weiter zu benutzen.</p>
</blockquote>
<p>jo denke mal auch, alles halb so wild.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/9752">@Dravere</a>, denke schon. <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/1850519</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1850519</guid><dc:creator><![CDATA[c.groupe]]></dc:creator><pubDate>Thu, 04 Feb 2010 15:45:35 GMT</pubDate></item></channel></rss>