<?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[bubbelsort ... Problem schon beim vertauschen von Zahlen]]></title><description><![CDATA[<p>hi,</p>
<p>ich versuche Bubbelsort zu implementieren. Ich hab das aufgeteilt in verschiedenen Datein (damit ich die Funktionen später für anderen Sortier-Algorithmen benutzen kann):</p>
<p>swap.hpp:</p>
<pre><code class="language-cpp">void (int *pa, int *pb)
{
	int temp = *pa;
	*pa = *pb;
	*pb = temp;
}
</code></pre>
<p>bubblesort.hpp</p>
<pre><code class="language-cpp">#include &quot;swap.hpp&quot;

bool bubblesort (int *array, int size)
{
	for (int i = 0; i &lt;= size - 1; i++)
	{
		for (int j = 0; j &lt;= size; j++)
			if (array[j] &gt; array[j + 1])
				swap (array[j], array[j + 1]);
	}
}
</code></pre>
<p>test.cpp</p>
<pre><code class="language-cpp">#include &quot;bubblesort.hpp&quot;

int main ()
{
	return 0;
}
</code></pre>
<p>g++ test.cpp</p>
<pre><code>In file included from bubblesort.hpp:1,
                 from test.cpp:1:
swap.hpp:1: error: expected unqualified-id before &quot;int&quot;
swap.hpp:1: error: expected `)' before &quot;int&quot;
swap.hpp:1: error: expected `,' or `;' before &quot;int&quot;
In file included from test.cpp:1:
bubblesort.hpp: In function `bool bubblesort(int*, int)':
bubblesort.hpp:9: error: `swap' undeclared (first use this function)
bubblesort.hpp:9: error: (Each undeclared identifier is reported only once for each function it appears in.)
</code></pre>
<p>Die Swap-Funktion ist Volkard's Kurs nachempfunden (<a href="http://www.volkard.de/vcppkold/bubble_sort.html" rel="nofollow">http://www.volkard.de/vcppkold/bubble_sort.html</a>) und sollte fast identisch sein.</p>
<p>Vielen Dank!</p>
<p>mfg</p>
<p>Joachim</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/136374/bubbelsort-problem-schon-beim-vertauschen-von-zahlen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 11:18:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/136374.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 09 Feb 2006 16:11:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to bubbelsort ... Problem schon beim vertauschen von Zahlen on Thu, 09 Feb 2006 16:11:07 GMT]]></title><description><![CDATA[<p>hi,</p>
<p>ich versuche Bubbelsort zu implementieren. Ich hab das aufgeteilt in verschiedenen Datein (damit ich die Funktionen später für anderen Sortier-Algorithmen benutzen kann):</p>
<p>swap.hpp:</p>
<pre><code class="language-cpp">void (int *pa, int *pb)
{
	int temp = *pa;
	*pa = *pb;
	*pb = temp;
}
</code></pre>
<p>bubblesort.hpp</p>
<pre><code class="language-cpp">#include &quot;swap.hpp&quot;

bool bubblesort (int *array, int size)
{
	for (int i = 0; i &lt;= size - 1; i++)
	{
		for (int j = 0; j &lt;= size; j++)
			if (array[j] &gt; array[j + 1])
				swap (array[j], array[j + 1]);
	}
}
</code></pre>
<p>test.cpp</p>
<pre><code class="language-cpp">#include &quot;bubblesort.hpp&quot;

int main ()
{
	return 0;
}
</code></pre>
<p>g++ test.cpp</p>
<pre><code>In file included from bubblesort.hpp:1,
                 from test.cpp:1:
swap.hpp:1: error: expected unqualified-id before &quot;int&quot;
swap.hpp:1: error: expected `)' before &quot;int&quot;
swap.hpp:1: error: expected `,' or `;' before &quot;int&quot;
In file included from test.cpp:1:
bubblesort.hpp: In function `bool bubblesort(int*, int)':
bubblesort.hpp:9: error: `swap' undeclared (first use this function)
bubblesort.hpp:9: error: (Each undeclared identifier is reported only once for each function it appears in.)
</code></pre>
<p>Die Swap-Funktion ist Volkard's Kurs nachempfunden (<a href="http://www.volkard.de/vcppkold/bubble_sort.html" rel="nofollow">http://www.volkard.de/vcppkold/bubble_sort.html</a>) und sollte fast identisch sein.</p>
<p>Vielen Dank!</p>
<p>mfg</p>
<p>Joachim</p>
]]></description><link>https://www.c-plusplus.net/forum/post/990228</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/990228</guid><dc:creator><![CDATA[j0achim]]></dc:creator><pubDate>Thu, 09 Feb 2006 16:11:07 GMT</pubDate></item><item><title><![CDATA[Reply to bubbelsort ... Problem schon beim vertauschen von Zahlen on Thu, 09 Feb 2006 16:32:09 GMT]]></title><description><![CDATA[<p>Die Swap-Funktion ist Volkard's Kurs nachempfunden (<a href="http://www.volkard.de/vcppkold/bubble_sort.html" rel="nofollow">http://www.volkard.de/vcppkold/bubble_sort.html</a>) und sollte fast identisch sein.</p>
<p>Vielen Dank!</p>
<p>mfg</p>
<p>Joachi<br />
[/quote]</p>
<p>warum hat die funktion keinen namen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/990245</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/990245</guid><dc:creator><![CDATA[golden_jubilee]]></dc:creator><pubDate>Thu, 09 Feb 2006 16:32:09 GMT</pubDate></item></channel></rss>