<?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-Klasse, Template-Funktionen und friend-Deklaration]]></title><description><![CDATA[<p>Hallo zusammen,<br />
ich versuche gerade für meine Prüfung einen Heapsort zu programmieren.<br />
Es funktioniert so lange bis ich die Klasse-Member als private deklariere, obwohl die zugreifenden globalen Methoden als friend deklariert sind.<br />
Warum? (ich bin mittlerweile sehr ratlos...)</p>
<pre><code class="language-cpp">#ifndef HEAPSORT_H
#define HEAPSORT_H

#include&lt;assert.h&gt;
#include&lt;vector&gt; 
#include&lt;iostream&gt;

typedef unsigned int uint;
using namespace std;

template&lt;typename T&gt;
class Heapsort
{

private:	
	vector&lt;T&gt; maxheap;
	vector&lt;T&gt; sortiertes_v;

public:
	Heapsort(vector&lt;T&gt; const&amp; v): sortiertes_v(), maxheap(v) {};

	friend void gen_maxheap(vector&lt;T&gt;&amp; v);
	friend void test_sinken(vector&lt;T&gt;&amp; v, uint i);
	friend void sortieralgo(vector&lt;T&gt; const&amp; v, Heapsort&lt;T&gt;&amp; ergebnis);
	inline void tausche(T&amp; v, T&amp; k);
	inline void print(vector&lt;T&gt; const&amp; v);
	inline void print(Heapsort&lt;T&gt; const&amp; v);

};

template&lt;typename T&gt;
void gen_maxheap(vector&lt;T&gt;&amp;  v)
{
	for(int i = (v.size() / 2 - 1) ; i &gt;= 0; i--)
	{
		test_sinken( v, i);

	}
}
template&lt;typename T&gt;
void test_sinken(vector&lt;T&gt;&amp; v, uint i)
{
	while(i &lt;= v.size() / 2 - 1)
	{
		uint kindindex = 2*i + 1;			//Index des linken Kindknotens
		if(kindindex+1 &lt;= v.size()-1)			//Rechtes Kind?
		{
			if(v[kindindex] &lt; v[kindindex+1])
				kindindex++;
		}

		if(v[i] &lt; v[kindindex])
		{
			tausche(v[i], v[kindindex]);
			i = kindindex;
		}
		else
			break;

	}
}

template&lt;typename T&gt;
void sortieralgo(vector&lt;T&gt;&amp; v, Heapsort&lt;T&gt;&amp; ergebnis)
{
	gen_maxheap&lt;T&gt;(ergebnis.maxheap);
	vector&lt;T&gt; w= ergebnis.maxheap;

	while(w.size() &gt; 0)
	{
		tausche(w.front(), w.back());
		(ergebnis.sortiertes_v).push_back(w.back());
		w.pop_back();
		if(w.size()==1)
		{
			(ergebnis.sortiertes_v).push_back(w.back());
			w.pop_back();
		}
		else
			test_sinken(w, 0);
	}
}

template&lt;typename T&gt;
	void tausche(T&amp; v, T&amp; k)
	{
		T temp = v;
		v = k;
		k = temp;
	};

template&lt;typename T&gt;
void print(vector&lt;T&gt; const&amp; v)
{
	for(uint i = 0; i &lt; v.size(); i++)
		{
			cout &lt;&lt; v[i] &lt;&lt; &quot; &quot; ;
		}
		cout &lt;&lt; endl;
}

template&lt;typename T&gt;
void print(Heapsort&lt;T&gt; const&amp; ergeb)
{
	print(ergeb.maxheap);
	print(ergeb.sortiertes_v);
}

#endif
</code></pre>
<p>error C2248: &quot;Heapsort&lt;T&gt;::maxheap&quot;: Kein Zugriff auf private Member, dessen Deklaration in der Heapsort&lt;T&gt;-Klasse erfolgte.</p>
<p>es kommen auch noch einige andere Fehlermeldungen, aber das ist zunächst denke ich das größte Problem...dass die Funktionen nicht auf die private Member zugreifen können.</p>
<p>Hab Ihr einen Tipp für mich woran das liegt?</p>
<p>Danke,<br />
Kathy</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/282796/template-klasse-template-funktionen-und-friend-deklaration</link><generator>RSS for Node</generator><lastBuildDate>Sat, 22 Aug 2026 23:39:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/282796.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 26 Feb 2011 19:54:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sat, 26 Feb 2011 19:54:52 GMT]]></title><description><![CDATA[<p>Hallo zusammen,<br />
ich versuche gerade für meine Prüfung einen Heapsort zu programmieren.<br />
Es funktioniert so lange bis ich die Klasse-Member als private deklariere, obwohl die zugreifenden globalen Methoden als friend deklariert sind.<br />
Warum? (ich bin mittlerweile sehr ratlos...)</p>
<pre><code class="language-cpp">#ifndef HEAPSORT_H
#define HEAPSORT_H

#include&lt;assert.h&gt;
#include&lt;vector&gt; 
#include&lt;iostream&gt;

typedef unsigned int uint;
using namespace std;

template&lt;typename T&gt;
class Heapsort
{

private:	
	vector&lt;T&gt; maxheap;
	vector&lt;T&gt; sortiertes_v;

public:
	Heapsort(vector&lt;T&gt; const&amp; v): sortiertes_v(), maxheap(v) {};

	friend void gen_maxheap(vector&lt;T&gt;&amp; v);
	friend void test_sinken(vector&lt;T&gt;&amp; v, uint i);
	friend void sortieralgo(vector&lt;T&gt; const&amp; v, Heapsort&lt;T&gt;&amp; ergebnis);
	inline void tausche(T&amp; v, T&amp; k);
	inline void print(vector&lt;T&gt; const&amp; v);
	inline void print(Heapsort&lt;T&gt; const&amp; v);

};

template&lt;typename T&gt;
void gen_maxheap(vector&lt;T&gt;&amp;  v)
{
	for(int i = (v.size() / 2 - 1) ; i &gt;= 0; i--)
	{
		test_sinken( v, i);

	}
}
template&lt;typename T&gt;
void test_sinken(vector&lt;T&gt;&amp; v, uint i)
{
	while(i &lt;= v.size() / 2 - 1)
	{
		uint kindindex = 2*i + 1;			//Index des linken Kindknotens
		if(kindindex+1 &lt;= v.size()-1)			//Rechtes Kind?
		{
			if(v[kindindex] &lt; v[kindindex+1])
				kindindex++;
		}

		if(v[i] &lt; v[kindindex])
		{
			tausche(v[i], v[kindindex]);
			i = kindindex;
		}
		else
			break;

	}
}

template&lt;typename T&gt;
void sortieralgo(vector&lt;T&gt;&amp; v, Heapsort&lt;T&gt;&amp; ergebnis)
{
	gen_maxheap&lt;T&gt;(ergebnis.maxheap);
	vector&lt;T&gt; w= ergebnis.maxheap;

	while(w.size() &gt; 0)
	{
		tausche(w.front(), w.back());
		(ergebnis.sortiertes_v).push_back(w.back());
		w.pop_back();
		if(w.size()==1)
		{
			(ergebnis.sortiertes_v).push_back(w.back());
			w.pop_back();
		}
		else
			test_sinken(w, 0);
	}
}

template&lt;typename T&gt;
	void tausche(T&amp; v, T&amp; k)
	{
		T temp = v;
		v = k;
		k = temp;
	};

template&lt;typename T&gt;
void print(vector&lt;T&gt; const&amp; v)
{
	for(uint i = 0; i &lt; v.size(); i++)
		{
			cout &lt;&lt; v[i] &lt;&lt; &quot; &quot; ;
		}
		cout &lt;&lt; endl;
}

template&lt;typename T&gt;
void print(Heapsort&lt;T&gt; const&amp; ergeb)
{
	print(ergeb.maxheap);
	print(ergeb.sortiertes_v);
}

#endif
</code></pre>
<p>error C2248: &quot;Heapsort&lt;T&gt;::maxheap&quot;: Kein Zugriff auf private Member, dessen Deklaration in der Heapsort&lt;T&gt;-Klasse erfolgte.</p>
<p>es kommen auch noch einige andere Fehlermeldungen, aber das ist zunächst denke ich das größte Problem...dass die Funktionen nicht auf die private Member zugreifen können.</p>
<p>Hab Ihr einen Tipp für mich woran das liegt?</p>
<p>Danke,<br />
Kathy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2026990</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2026990</guid><dc:creator><![CDATA[Kathy88]]></dc:creator><pubDate>Sat, 26 Feb 2011 19:54:52 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sat, 26 Feb 2011 20:04:11 GMT]]></title><description><![CDATA[<p>gcc sagt</p>
<blockquote>
<p>C:\irgendwo\main.cpp|22|warning: friend declaration 'void gen_maxheap(std::vector&lt;T&gt;&amp;)' declares a non-template function|</p>
</blockquote>
<pre><code class="language-cpp">template&lt;typename T&gt;
class Heapsort
{

private:	
	vector&lt;T&gt; maxheap;
	vector&lt;T&gt; sortiertes_v;

public:
	Heapsort(vector&lt;T&gt; const&amp; v): sortiertes_v(), maxheap(v) {};

        template&lt;typename U&gt; friend void gen_maxheap(vector&lt;U&gt;&amp; v);
...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2026993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2026993</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sat, 26 Feb 2011 20:04:11 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sat, 26 Feb 2011 20:10:16 GMT]]></title><description><![CDATA[<p>aber wenn ich das ändere kommen die gleichen Fehlermeldungen immer noch...</p>
<p>heapsort_klasse.h(69): error C2248: &quot;Heapsort&lt;T&gt;::maxheap&quot;: Kein Zugriff auf private Member, dessen Deklaration in der Heapsort&lt;T&gt;-Klasse erfolgte.<br />
1&gt; with<br />
1&gt; [<br />
1&gt; T=char<br />
1&gt; ]</p>
<p>das ist die erste...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2026996</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2026996</guid><dc:creator><![CDATA[Kathy88]]></dc:creator><pubDate>Sat, 26 Feb 2011 20:10:16 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sat, 26 Feb 2011 20:16:10 GMT]]></title><description><![CDATA[<p>Kathy88 schrieb:</p>
<blockquote>
<p>aber wenn ich das ändere kommen die gleichen Fehlermeldungen immer noch...</p>
<p>heapsort_klasse.h(69): error C2248: &quot;Heapsort&lt;T&gt;::maxheap&quot;: Kein Zugriff auf private Member, dessen Deklaration in der Heapsort&lt;T&gt;-Klasse erfolgte.<br />
1&gt; with<br />
1&gt; [<br />
1&gt; T=char<br />
1&gt; ]</p>
<p>das ist die erste...</p>
</blockquote>
<p>Komisch. Aber ich konnte auch nicht so gut testen, weil ich keine main() zum testen hatte, und weil ich auch gar nicht verstanden hatte, was die Klasse da soll und die friend-Funktionen (besser static?) und ich war ganz durcheinander.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027002</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027002</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sat, 26 Feb 2011 20:16:10 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sat, 26 Feb 2011 20:19:41 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include&lt;cassert&gt;
#include&lt;vector&gt; 
#include&lt;iostream&gt;
#include &quot;Heapsort_Klasse.h&quot;

using namespace std;

typedef unsigned int uint;

int main()
{
	vector&lt;char&gt; v;
	v.push_back('H');
	v.push_back('E');
	v.push_back('A');
	v.push_back('P');
	v.push_back('S');
	v.push_back('O');
	v.push_back('R');
	v.push_back('T');

	Heapsort&lt;char&gt; ergebnis(v);
	sortieralgo(v,ergebnis);		//Aufruf des sortieralgorithmus
	print(v);
	print(ergebnis);

	system (&quot;pause&quot;);
	return 0;
}
</code></pre>
<p>Das ist die main dazu. Das Programm soll ein &quot;Vorführprogramm&quot; für die Prüfung sein, daher hab ich versucht so viele Dinge wie möglich zu &quot;zeigen&quot;.<br />
man kann das ganze auch ohne klasse machen...läuft auch.</p>
<p>Ich verstehe halt bloß nicht warum trotz friend die keinen Zugriff haben soll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027005</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027005</guid><dc:creator><![CDATA[kathy88]]></dc:creator><pubDate>Sat, 26 Feb 2011 20:19:41 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sat, 26 Feb 2011 20:40:31 GMT]]></title><description><![CDATA[<p>mal grad ne andere frage, du deklarierst da noch 3 methoden (tausche und 2x print)</p>
<p>und unten definierst du diese, sofern ich das richtig sehe.<br />
aber du schreibst dort:</p>
<pre><code class="language-cpp">template&lt;typename T&gt;
void print(Heapsort&lt;T&gt; const&amp; ergeb)
{
    print(ergeb.maxheap);
    print(ergeb.sortiertes_v);
}
</code></pre>
<p>anstelle von</p>
<pre><code class="language-cpp">template&lt;typename T&gt;
void Heapsort&lt;T&gt;::print(Heapsort&lt;T&gt; const&amp; ergeb)
{
    print(ergeb.maxheap);
    print(ergeb.sortiertes_v);
}
</code></pre>
<p>ist das gewollt?<br />
weil das ist eigentlich auch ein fehler...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027008</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027008</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Sat, 26 Feb 2011 20:40:31 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sat, 26 Feb 2011 20:39:18 GMT]]></title><description><![CDATA[<p>Einmal const vergessen (dadurch war der Freund eine andere als die, die es echt gab) und einmal friend (dadurch war die existierende print gar kein friend).</p>
<pre><code class="language-cpp">#ifndef HEAPSORT_H
#define HEAPSORT_H

#include&lt;assert.h&gt;
#include&lt;vector&gt;
#include&lt;iostream&gt;

typedef unsigned int uint;
using namespace std;

template&lt;typename T&gt;
class Heapsort
{

private:
    vector&lt;T&gt; maxheap;
    vector&lt;T&gt; sortiertes_v;

public:
    Heapsort(vector&lt;T&gt; const&amp; v): sortiertes_v(), maxheap(v) {};

//    template&lt;typename U&gt; friend void gen_maxheap(vector&lt;U&gt;&amp; v);
//    template&lt;typename U&gt; friend void test_sinken(vector&lt;U&gt;&amp; v, uint i);
    template&lt;typename U&gt; friend void sortieralgo(vector&lt;U&gt; const&amp; v, Heapsort&lt;U&gt;&amp; ergebnis);
//    template&lt;typename U&gt; inline void tausche(U&amp; v, U&amp; k);
//    template&lt;typename U&gt; inline void print(vector&lt;U&gt; const&amp; v);
    template&lt;typename U&gt; friend inline void print(Heapsort&lt;U&gt; const&amp; v);

};

template&lt;typename T&gt;
void gen_maxheap(vector&lt;T&gt;&amp;  v)
{
    for(int i = (v.size() / 2 - 1) ; i &gt;= 0; i--)
    {
        test_sinken( v, i);

    }
}
template&lt;typename T&gt;
void test_sinken(vector&lt;T&gt;&amp; v, uint i)
{
    while(i &lt;= v.size() / 2 - 1)
    {
        uint kindindex = 2*i + 1;            //Index des linken Kindknotens
        if(kindindex+1 &lt;= v.size()-1)            //Rechtes Kind?
        {
            if(v[kindindex] &lt; v[kindindex+1])
                kindindex++;
        }

        if(v[i] &lt; v[kindindex])
        {
            tausche(v[i], v[kindindex]);
            i = kindindex;
        }
        else
            break;

    }
}

template&lt;typename T&gt;
void sortieralgo(vector&lt;T&gt; const&amp; v, Heapsort&lt;T&gt;&amp; ergebnis)
{
    gen_maxheap&lt;T&gt;(ergebnis.maxheap);
    vector&lt;T&gt; w= ergebnis.maxheap;

    while(w.size() &gt; 0)
    {
        tausche(w.front(), w.back());
        (ergebnis.sortiertes_v).push_back(w.back());
        w.pop_back();
        if(w.size()==1)
        {
            (ergebnis.sortiertes_v).push_back(w.back());
            w.pop_back();
        }
        else
            test_sinken(w, 0);
    }
}

template&lt;typename T&gt;
void tausche(T&amp; v, T&amp; k)
{
    T temp = v;
    v = k;
    k = temp;
};

template&lt;typename T&gt;
void print(vector&lt;T&gt; const&amp; v)
{
    for(uint i = 0; i &lt; v.size(); i++)
    {
        cout &lt;&lt; v[i] &lt;&lt; &quot; &quot; ;
    }
    cout &lt;&lt; endl;
}

template&lt;typename T&gt;
void print(Heapsort&lt;T&gt; const&amp; ergeb)
{
    print(ergeb.maxheap);
    print(ergeb.sortiertes_v);
}

#endif

#include&lt;cassert&gt;
#include&lt;vector&gt;
#include&lt;iostream&gt;
//#include &quot;Heapsort_Klasse.h&quot;

using namespace std;

typedef unsigned int uint;

int main()
{
    vector&lt;char&gt; v;
    v.push_back('H');
    v.push_back('E');
    v.push_back('A');
    v.push_back('P');
    v.push_back('S');
    v.push_back('O');
    v.push_back('R');
    v.push_back('T');

    Heapsort&lt;char&gt; ergebnis(v);
    sortieralgo(v,ergebnis);        //Aufruf des sortieralgorithmus
    print(v);
    print(ergebnis);

//    system (&quot;pause&quot;);
    cin.get();
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2027011</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027011</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sat, 26 Feb 2011 20:39:18 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sat, 26 Feb 2011 21:08:22 GMT]]></title><description><![CDATA[<p>lol?</p>
<p>ich hab jetzt rumprobiert und gemacht und getan</p>
<p>mittendrin kamst du mir zuvor<br />
hast quasi nichts verändert und es läuft alles!!!</p>
<p>das einzige was du jetzt anders gemacht hast ist, dass du statt</p>
<pre><code class="language-cpp">friend void sortieralgo(vector&lt;T&gt; const&amp; v, Heapsort&lt;T&gt;&amp; ergebnis);
</code></pre>
<p>das hier geschreiben hast</p>
<pre><code class="language-cpp">template&lt;typename U&gt; friend void sortieralgo(vector&lt;U&gt; const&amp; v, Heapsort&lt;U&gt;&amp; ergebnis);
</code></pre>
<p>also das template mit namen anders gesetzt hast, oder sehe ich das falsch?<br />
(das gleiche analog mit der adneren funktion)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027018</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027018</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Sat, 26 Feb 2011 21:08:22 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sat, 26 Feb 2011 21:22:24 GMT]]></title><description><![CDATA[<p>Ja, und bei</p>
<pre><code class="language-cpp">inline void print(Heapsort&lt;T&gt; const&amp; v);
</code></pre>
<p>auch das friend dazugemacht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027025</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027025</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sat, 26 Feb 2011 21:22:24 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 09:13:32 GMT]]></title><description><![CDATA[<p>Supi, vielen, vielen Dank!<br />
Es funktioniert. Hab die ganzen U's nur wieder in T' umgewandelt, damit es konsistent ist, oder hatte das einen speziellen Grund warum die in der Deklaration der Funktionen in der Klasse U statt T genommen hast?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027105</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027105</guid><dc:creator><![CDATA[Kathy88]]></dc:creator><pubDate>Sun, 27 Feb 2011 09:13:32 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 09:31:16 GMT]]></title><description><![CDATA[<p>Ich hätte da jetzt noch nen kleinen anderen Wunsch. Um die verschiedenen Möglichkeiten der Funktionsdefinition aufzuzeigen würde ich gerne die print-Funktion die ein Heapsort-Argument hat als Memberfunktion schreiben, also so:</p>
<pre><code class="language-cpp">template&lt;typename T&gt; void print()
	{
    print(maxheap);
    print(sortiertes_v);
	}
</code></pre>
<p>und rufe die dann auf mit:</p>
<pre><code class="language-cpp">ergebnis.print();
</code></pre>
<p>Dann bekomme ich aber die folgenden Fehler:</p>
<p>error C2783: &quot;void Heapsort&lt;T&gt;::print(void)&quot;: template-Argument für &quot;T&quot; konnte nicht hergeleitet werden.</p>
<p>error C2780: 'void Heapsort&lt;T&gt;::print(const std::vector&lt;T&gt; &amp;)': Erwartet 1 Argumente - 0 unterstützt</p>
<p>Wo liegt mein Fehler in der Definition?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027110</guid><dc:creator><![CDATA[Kathy88]]></dc:creator><pubDate>Sun, 27 Feb 2011 09:31:16 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 09:32:39 GMT]]></title><description><![CDATA[<p>ja wenn man T für den klassen template parameter wählt und in dieser andere template funktionen (als friends) deklariert, muss das ja nicht heissen dass die parameter gleich oder verschieden sind.</p>
<p>folglich sollte man den klassen parameter T(oder auch was belibiges anderes) nennen und die funktions templates innerhalb der klasse U. ob die definitionen auch diesen parameter haben ist eig egal...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027111</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027111</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Sun, 27 Feb 2011 09:32:39 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 09:33:43 GMT]]></title><description><![CDATA[<p>Jetzt hast du dort eine Template-Funktion, bei der der Compiler mangels abhängiger Typen in der Parameter-Liste nicht entscheiden kann, für welches T er die Funktion generieren soll. In der Tat ist die Funktion aber auch unabhängig von T, wie es ausschaut.<br />
Ein Aufruf müsste zur Zeit so aussehen:</p>
<pre><code class="language-cpp">ergebnis.print&lt;int&gt;();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2027112</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027112</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 27 Feb 2011 09:33:43 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 09:41:52 GMT]]></title><description><![CDATA[<p>Also du meinst ich könnte das template... weglassen?<br />
Mit dem Aufruf</p>
<pre><code class="language-cpp">ergebnis.print&lt;char&gt;();
</code></pre>
<p>geht es leider auch nicht.</p>
<p>Hab noch überlegt ob ich dann in die Funktion void print() const</p>
<pre><code class="language-cpp">print&lt;T&gt;(maxheap);
print&lt;T&gt;(sortiertes_v);
</code></pre>
<p>schreiben muss, aber auch das geht nicht.<br />
Da kommt dann:<br />
error C2662: 'void Heapsort&lt;T&gt;::print&lt;T&gt;(const std::vector&lt;_Ty&gt; &amp;)': this-Zeiger kann nicht von 'const Heapsort&lt;T&gt;' in 'Heapsort&lt;T&gt; &amp;' konvertiert werden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027116</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027116</guid><dc:creator><![CDATA[Kathy88]]></dc:creator><pubDate>Sun, 27 Feb 2011 09:41:52 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 09:45:03 GMT]]></title><description><![CDATA[<p>Was bedeutet &quot;Es geht leider nicht&quot; genau? Was sagt der Compiler dazu?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027117</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027117</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 27 Feb 2011 09:45:03 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 09:50:06 GMT]]></title><description><![CDATA[<p>Also die Funktion sieht jetzt so aus:</p>
<pre><code class="language-cpp">template&lt;typename T&gt; 
   void print()
  {
    print(maxheap);
    print(sortiertes_v);
  }
</code></pre>
<p>und der Aufruf so:</p>
<pre><code class="language-cpp">ergebnis.print&lt;char&gt;();
</code></pre>
<p>dann sagt er:</p>
<p>error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: void __thiscall Heapsort&lt;char&gt;::print&lt;char&gt;(class std::vector&lt;char,class std::allocator&lt;char&gt; &gt; const &amp;)&quot; (??<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>p</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>t</mi><mi mathvariant="normal">@</mi><mi>D</mi><mi mathvariant="normal">@</mi><mo>?</mo></mrow><annotation encoding="application/x-tex">print@D@?</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:0.8888799999999999em;vertical-align:-0.19444em;"></span><span class="base textstyle uncramped"><span class="mord mathit">p</span><span class="mord mathit" style="margin-right:0.02778em;">r</span><span class="mord mathit">i</span><span class="mord mathit">n</span><span class="mord mathit">t</span><span class="mord mathrm">@</span><span class="mord mathit" style="margin-right:0.02778em;">D</span><span class="mord mathrm">@</span><span class="mclose">?</span></span></span></span>Heapsort@D@@QAEXABV?<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>v</mi><mi>e</mi><mi>c</mi><mi>t</mi><mi>o</mi><mi>r</mi><mi mathvariant="normal">@</mi><mi>D</mi><mi>V</mi><mo>?</mo></mrow><annotation encoding="application/x-tex">vector@DV?</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:0.69444em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.03588em;">v</span><span class="mord mathit">e</span><span class="mord mathit">c</span><span class="mord mathit">t</span><span class="mord mathit">o</span><span class="mord mathit" style="margin-right:0.02778em;">r</span><span class="mord mathrm">@</span><span class="mord mathit" style="margin-right:0.02778em;">D</span><span class="mord mathit" style="margin-right:0.22222em;">V</span><span class="mclose">?</span></span></span></span>allocator@D@std@@@std@@@Z)&quot; in Funktion &quot;&quot;public: void __thiscall Heapsort&lt;char&gt;::print&lt;char&gt;(void)&quot; (??<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>p</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>t</mi><mi mathvariant="normal">@</mi><mi>D</mi><mi mathvariant="normal">@</mi><mo>?</mo></mrow><annotation encoding="application/x-tex">print@D@?</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:0.8888799999999999em;vertical-align:-0.19444em;"></span><span class="base textstyle uncramped"><span class="mord mathit">p</span><span class="mord mathit" style="margin-right:0.02778em;">r</span><span class="mord mathit">i</span><span class="mord mathit">n</span><span class="mord mathit">t</span><span class="mord mathrm">@</span><span class="mord mathit" style="margin-right:0.02778em;">D</span><span class="mord mathrm">@</span><span class="mclose">?</span></span></span></span>Heapsort@D@@QAEXXZ)&quot;.</p>
<p>und</p>
<p>fatal error LNK1120: 1 nicht aufgelöste externe Verweise.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027121</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027121</guid><dc:creator><![CDATA[kathy88]]></dc:creator><pubDate>Sun, 27 Feb 2011 09:50:06 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 09:58:31 GMT]]></title><description><![CDATA[<p>Naja, er findet jetzt keine Implementierung der print-Funktion, die ein &quot;const std::vector&lt;char&gt;&amp;&quot; verlangt...</p>
<p>Aber wie du schon sagtest, die template-Sache ist eigentlich völlig unnötig bei dieser Funktion. Alle Funktionen in einem Klassentemplate sind schon implizit von den Template-Parametern der Klasse abhängig, das heißt, solange die Funktion nicht noch von einem anderen Typ abhängen soll, kannst du dir eine template-Methode sparen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027124</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027124</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 27 Feb 2011 09:58:31 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 10:02:08 GMT]]></title><description><![CDATA[<p>Ok, wenn ich jetzt aber schreibe</p>
<pre><code class="language-cpp">void print()
{
    print(maxheap);
    print(sortiertes_v);
}
</code></pre>
<p>sagt der Compiler mir:</p>
<p>error C2780: 'void Heapsort&lt;T&gt;::print(const std::vector&lt;T&gt; &amp;)': Erwartet 1 Argumente - 0 unterstützt</p>
<p>Was muss ich denn da jetzt noch verändert, dass der Aufruf funktioniert-</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027132</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027132</guid><dc:creator><![CDATA[Kathy88]]></dc:creator><pubDate>Sun, 27 Feb 2011 10:02:08 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 10:04:50 GMT]]></title><description><![CDATA[<p>oder noch besser wäre:</p>
<pre><code class="language-cpp">void print() const
{
    print(maxheap);
    print(sortiertes_v);
}
</code></pre>
<p>aber da kommt auch wieder</p>
<p>error C2780: 'void Heapsort&lt;T&gt;::print(const std::vector&lt;T&gt; &amp;)': Erwartet 1 Argumente - 0 unterstützt<br />
1&gt; with<br />
1&gt; [<br />
1&gt; T=char<br />
1&gt; ]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027134</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027134</guid><dc:creator><![CDATA[Kathy88]]></dc:creator><pubDate>Sun, 27 Feb 2011 10:04:50 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 10:15:45 GMT]]></title><description><![CDATA[<p>Kannst du bitte deinen aktuellen Quelltext nochmal ganz posten? Ich weiß ja nicht, ob du die inkorrekte definition der Methoden außerhalb der Klasse inzwischen schon gefixt hast usw.</p>
<p>Und irgendwie muss ich auch mal anmerken, dass mir die ganze Klasse mit ihren friend-Funktionen da ziemlich komisch und undurchsichtig anmutet!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027136</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027136</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 27 Feb 2011 10:15:45 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 11:12:42 GMT]]></title><description><![CDATA[<p>Also der komplette Quelltext, Header und cpp-Datei</p>
<pre><code class="language-cpp">#ifndef HEAPSORT_H
#define HEAPSORT_H

#include&lt;assert.h&gt;
#include&lt;vector&gt;
#include&lt;iostream&gt;

typedef unsigned int uint; 
using namespace std;

template&lt;typename T&gt;
class Heapsort
{

private:
    vector&lt;T&gt; maxheap;
    vector&lt;T&gt; sortiertes_v;

public:
    Heapsort(vector&lt;T&gt; const&amp; v): sortiertes_v(), maxheap(v) {};

    template&lt;typename T&gt; friend void gen_maxheap(vector&lt;T&gt;&amp; v);
	template&lt;typename T&gt; friend void test_sinken(vector&lt;T&gt;&amp; v, uint i);
    template&lt;typename T&gt; friend void sortieralgo(vector&lt;T&gt; const&amp; v, Heapsort&lt;T&gt;&amp; ergebnis);
    template&lt;typename T&gt; inline void tausche(T&amp; v, T&amp; k);
    template&lt;typename T&gt; inline void print(vector&lt;T&gt; const&amp; v);
	//template&lt;typename T&gt; friend inline void print(Heapsort&lt;T&gt; const&amp; v);

	void print() const
	{
    print(maxheap);
    print(sortiertes_v);
	}

};

template&lt;typename T&gt;
void gen_maxheap(vector&lt;T&gt;&amp;  v)
{
    for(int i = (v.size() / 2 - 1) ; i &gt;= 0; i--)
    {
        test_sinken( v, i);

    }
}
template&lt;typename T&gt;
void test_sinken(vector&lt;T&gt;&amp; v, uint i)
{
    while(i &lt;= v.size() / 2 - 1)
    {
        uint kindindex = 2*i + 1;            //Index des linken Kindknotens
        if(kindindex+1 &lt;= v.size()-1)            //Rechtes Kind?
        {
            if(v[kindindex] &lt; v[kindindex+1])
                kindindex++;
        }

        if(v[i] &lt; v[kindindex])
        {
            tausche(v[i], v[kindindex]);
            i = kindindex;
        }
        else
            break;

    }
}

template&lt;typename T&gt;
void sortieralgo(vector&lt;T&gt; const&amp; v, Heapsort&lt;T&gt;&amp; ergebnis)
{
    gen_maxheap&lt;T&gt;(ergebnis.maxheap);
    vector&lt;T&gt; w= ergebnis.maxheap;

    while(w.size() &gt; 0)
    {
        tausche(w.front(), w.back());
        (ergebnis.sortiertes_v).push_back(w.back());
        w.pop_back();
        if(w.size()==1)
        {
            (ergebnis.sortiertes_v).push_back(w.back());
            w.pop_back();
        }
        else
            test_sinken(w, 0);
    }
}

template&lt;typename T&gt;
void tausche(T&amp; v, T&amp; k)
{
    T temp = v; 
    v = k;
    k = temp;
};

template&lt;typename T&gt;
void print(vector&lt;T&gt; const&amp; v)
{
    for(uint i = 0; i &lt; v.size(); i++)
    {
        cout &lt;&lt; v[i] &lt;&lt; &quot; &quot; ;
    }
    cout &lt;&lt; endl;
}

//template&lt;typename T&gt;
//void print(Heapsort&lt;T&gt; const&amp; ergeb)
//{
//    print(ergeb.maxheap);
//    print(ergeb.sortiertes_v);
//}

#endif

#include&lt;cassert&gt;
#include&lt;vector&gt;
#include&lt;iostream&gt;
#include &quot;Heapsort_Prüfung.h&quot;

using namespace std;

typedef unsigned int uint;

int main()
{
    vector&lt;char&gt; v;
    v.push_back('H');
    v.push_back('E');
    v.push_back('A');
    v.push_back('P');
    v.push_back('S');
    v.push_back('O');
    v.push_back('R');
    v.push_back('T');

    Heapsort&lt;char&gt; ergebnis(v);
    sortieralgo(v,ergebnis);        //Aufruf des sortieralgorithmus
    print(v);
	ergebnis.print&lt;char&gt;();
	//print(ergebnis);
    //ergebnis.print&lt;char&gt;();

	system (&quot;pause&quot;);
    // cin.get();
    return 0;
}
</code></pre>
<p>was meinst du denn mit undurchsichtig? ich hab halt für die Prüfung versucht möglichst viele Möglichkeiten, die C++ bietet in den Code zu packen, d.h. z.B das mit der friend Deklaration.</p>
<p>Ich hätte die private Klassenmember auch public machen können, da wäre das um einiges einfacher und ich hätte auch keine Klasse für den ganzen Code gebraucht...so musste ich eben noch zwei Klassenmember &quot;erfinden&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027164</guid><dc:creator><![CDATA[Kathy88]]></dc:creator><pubDate>Sun, 27 Feb 2011 11:12:42 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 11:15:08 GMT]]></title><description><![CDATA[<p>So hab grade gemerkt, dass der Aufruf jetzt falsch ist, aber auch wenn ich das korrigiere kommen noch Fehler:</p>
<pre><code class="language-cpp">#include&lt;cassert&gt;
#include&lt;vector&gt;
#include&lt;iostream&gt;
#include &quot;Heapsort_Prüfung.h&quot;

using namespace std;

typedef unsigned int uint;

int main()
{
    vector&lt;char&gt; v;
    v.push_back('H');
    v.push_back('E');
    v.push_back('A');
    v.push_back('P');
    v.push_back('S');
    v.push_back('O');
    v.push_back('R');
    v.push_back('T');

    Heapsort&lt;char&gt; ergebnis(v);
    sortieralgo(v,ergebnis);        //Aufruf des sortieralgorithmus
    print(v);
	ergebnis.print();
	//print(ergebnis);
    //ergebnis.print&lt;char&gt;();

	system (&quot;pause&quot;);
    // cin.get();
    return 0;
}
</code></pre>
<p>Fehler:</p>
<p>rror C2663: 'Heapsort&lt;T&gt;::print': für 2 Überladung(en) gibt es keine zulässige Konvertierung für den this-Zeiger<br />
1&gt; with<br />
1&gt; [<br />
1&gt; T=char<br />
1&gt; ]</p>
<p>und noch einiges mehr... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027166</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027166</guid><dc:creator><![CDATA[Kathy88]]></dc:creator><pubDate>Sun, 27 Feb 2011 11:15:08 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 12:08:37 GMT]]></title><description><![CDATA[<p>Wofür ist die Heapsort-Klasse eigentlich gut, wenn du alles mit friend-Funktionen außerhalb der Klasse machst? Ich verstehe den ganzen Ansatz nicht, und warum deklarierst du Funktionen als friends, die gar nicht auf private-member von der Klasse zugreifen?<br />
Warum benutzt du inline? Warum deklarierst du Member-Funktionen und versuchst sie dann als freie Funktionen zu implementieren?<br />
Mir tut das im Gehirn weh, wenn ich das da vor mir sehe <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /><br />
Also was ich meine ist, du hast da noch viel grundlegendere Probleme als nur die Compiler-Fehler, im Moment.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027187</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 27 Feb 2011 12:08:37 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 12:17:45 GMT]]></title><description><![CDATA[<p>Und vor allem: Warum ist Heapsort überhaupt eine Klasse? Wir sind hier nicht bei Java, sondern können auch freie Funktionen definieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027190</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027190</guid><dc:creator><![CDATA[Ieek!]]></dc:creator><pubDate>Sun, 27 Feb 2011 12:17:45 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 12:27:27 GMT]]></title><description><![CDATA[<p>also wäre so besser...</p>
<pre><code class="language-cpp">#include&lt;cassert&gt;
#include&lt;vector&gt; 
#include&lt;iostream&gt;

using namespace std;

typedef unsigned int uint;

template&lt;typename T&gt;						//Array vom Typ T zur Sortierung
void gen_maxheap(vector&lt;T&gt;&amp; v)
{
	for(int i = (v.size() / 2 - 1) ; i &gt;= 0; i--)
	{
		test_sinken( v, i);

	}
}
template&lt;typename T&gt;
void test_sinken(vector&lt;T&gt;&amp; v, uint i)
{
	while(i &lt;= v.size() / 2 - 1)
	{
		uint kindindex = 2*i + 1;			//Index des linken Kindknotens
		if(kindindex+1 &lt;= v.size()-1)			//Rechtes Kind?
		{
			if(v[kindindex] &lt; v[kindindex+1])
				kindindex++;
		}

		if(v[i] &lt; v[kindindex])
		{
			tausche(v[i], v[kindindex]);
			i = kindindex;
		}
		else
			break;

	}
}

template&lt;typename T&gt;
void heapsort(vector&lt;T&gt;&amp; v, vector&lt;T&gt;&amp; sortiertes_v)
{
gen_maxheap(v);
print(v);
	while(v.size() &gt; 0)
	{
		tausche(v.front(), v.back());
		sortiertes_v.push_back(v.back());
		v.pop_back();
		if(v.size()==1)
		{
			sortiertes_v.push_back(v.back());
			v.pop_back();
		}
		else
			test_sinken(v, 0);

	}
}
template&lt;typename T&gt;
void inline tausche(T&amp; v, T&amp; k)
{
	T temp = v;
	v = k;
	k = temp;
}

template&lt;typename T&gt;
void inline print(vector&lt;T&gt; const&amp; v)
{
	for(uint i = 0; i &lt; v.size(); i++)
		{
			cout &lt;&lt; v[i] &lt;&lt; &quot; &quot; ;
		}
		cout &lt;&lt; endl;
}

int main()
{
	vector&lt;char&gt; v;
	v.push_back('H');
	v.push_back('E');
	v.push_back('A');
	v.push_back('P');
	v.push_back('S');
	v.push_back('O');
	v.push_back('R');
	v.push_back('T');

	vector&lt;char&gt; sortiertes_v;
	heapsort(v, sortiertes_v);
	print(sortiertes_v);

	system (&quot;pause&quot;);
	return 0;
}
</code></pre>
<p>Ich hatte ja schon mal geschrieben, dass das ein Programm ist, was ich zur mündlichen Prüfung mitnehme. Und da habe ich versucht viele c++ Features reinzupacken, d.h. neben Template-Klasse auch Template-Funktionen, include &quot;Header.h&quot;, freind-Deklaration um auf private member zuzugreifen usw.<br />
Den Code den ich jetzt hochgeladen habe der macht im Prinzip das gleiche...nur eben mit weniger Features...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027194</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027194</guid><dc:creator><![CDATA[Kathy88]]></dc:creator><pubDate>Sun, 27 Feb 2011 12:27:27 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse, Template-Funktionen und friend-Deklaration on Sun, 27 Feb 2011 12:40:16 GMT]]></title><description><![CDATA[<p>Naja, du könntest den Sortier-Algo zB. für den Vergleich (Also die Ordnung template'isieren. Und dann nen Vergleichs-Funktor mitgeben oder sowas.</p>
<p>Die Ausgabe könntest du durch überladung des &lt;&lt; Operators implementieren. Das wäre alles &quot;sinnvoll&quot; und würde zusätzlich noch etwas von C++ zeigen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2027199</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2027199</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 27 Feb 2011 12:40:16 GMT</pubDate></item></channel></rss>