<?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[Vererbung und Templates]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich versuche mit QT eine Templateklasse an eine andere Templateklasse zu vererben. Aber ich bekomme immer die Fehlermeldung (dick markierte Zeile):</p>
<blockquote>
<p>expected template-name before '&lt;'</p>
</blockquote>
<p>Basisklasse:</p>
<pre><code>/*
#ifndef _SORTINGALGORITHM_H_INCLUDED_
#define _SORTINGALGORITHM_H_INCLUDED_

#include &quot;svn/control/disposercontrol.h&quot;
#include &lt;iostream&gt;
using namespace std;

template &lt;class T&gt;
class SortingAlgorithm
{
//---------------------------------------------------------
public:
// Konstruktoren
     SortingAlgorithm(int size = 0);
    ~SortingAlgorithm();

private:
// Attribute
    int size;
    double tact;
    T sortingArray;
    SortingAlgorithm* disposer;

};

#endif
</code></pre>
<pre><code>// Konstruktor
template &lt;class T&gt;
SortingAlgorithm&lt;T&gt;::SortingAlgorithm(int size)
{
}
</code></pre>
<p>Unterklasse:</p>
<pre><code>/*
Name: selectionsort.h
Autor: Kevin Klein
Datum: 30.05.2012
Beschreibung: Vererbung von Klassen im Model
*/

#ifndef _SELECTIONSORT_H_INCLUDED_
#define _SELECTIONSORT_H_INCLUDED_

#include &quot;svn/control/disposercontrol.h&quot;
#include &quot;svn/model/sortingAlgorithm.h&quot;
#include &lt;iostream&gt;

template &lt;class T&gt;
[b]class Selectionsort : public SortingAlgorithm&lt;T&gt;[/b]
{
public:
// Konstruktoren
    Selectionsort(int size) : SortingAlgorithm&lt;T&gt;(size) {}

// Destruktor
    ~Selectionsort();

private:

};

#endif /*_SELECTIONSORT_H_INCLUDED_ */
</code></pre>
<pre><code>#include &quot;selectionsort.h&quot;

// Konstruktor

template &lt;class T&gt;
Selectionsort::Selectionsort(int size) : SortingAlgorithm&lt;T&gt;(size)
{

}
</code></pre>
<p>Und erstellen tu ich das dann so:</p>
<pre><code>Selectionsort&lt;int&gt; *sort = new Selectionsort&lt;int&gt;(size)
</code></pre>
<p>Wo ist mein Fehler?<br />
Vielen Dank im voraus für eure Hilfe!</p>
<p>Karlsberg_86</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/304909/vererbung-und-templates</link><generator>RSS for Node</generator><lastBuildDate>Sat, 27 Jun 2026 15:29:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/304909.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 16 Jun 2012 19:42:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Vererbung und Templates on Sat, 16 Jun 2012 19:42:39 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich versuche mit QT eine Templateklasse an eine andere Templateklasse zu vererben. Aber ich bekomme immer die Fehlermeldung (dick markierte Zeile):</p>
<blockquote>
<p>expected template-name before '&lt;'</p>
</blockquote>
<p>Basisklasse:</p>
<pre><code>/*
#ifndef _SORTINGALGORITHM_H_INCLUDED_
#define _SORTINGALGORITHM_H_INCLUDED_

#include &quot;svn/control/disposercontrol.h&quot;
#include &lt;iostream&gt;
using namespace std;

template &lt;class T&gt;
class SortingAlgorithm
{
//---------------------------------------------------------
public:
// Konstruktoren
     SortingAlgorithm(int size = 0);
    ~SortingAlgorithm();

private:
// Attribute
    int size;
    double tact;
    T sortingArray;
    SortingAlgorithm* disposer;

};

#endif
</code></pre>
<pre><code>// Konstruktor
template &lt;class T&gt;
SortingAlgorithm&lt;T&gt;::SortingAlgorithm(int size)
{
}
</code></pre>
<p>Unterklasse:</p>
<pre><code>/*
Name: selectionsort.h
Autor: Kevin Klein
Datum: 30.05.2012
Beschreibung: Vererbung von Klassen im Model
*/

#ifndef _SELECTIONSORT_H_INCLUDED_
#define _SELECTIONSORT_H_INCLUDED_

#include &quot;svn/control/disposercontrol.h&quot;
#include &quot;svn/model/sortingAlgorithm.h&quot;
#include &lt;iostream&gt;

template &lt;class T&gt;
[b]class Selectionsort : public SortingAlgorithm&lt;T&gt;[/b]
{
public:
// Konstruktoren
    Selectionsort(int size) : SortingAlgorithm&lt;T&gt;(size) {}

// Destruktor
    ~Selectionsort();

private:

};

#endif /*_SELECTIONSORT_H_INCLUDED_ */
</code></pre>
<pre><code>#include &quot;selectionsort.h&quot;

// Konstruktor

template &lt;class T&gt;
Selectionsort::Selectionsort(int size) : SortingAlgorithm&lt;T&gt;(size)
{

}
</code></pre>
<p>Und erstellen tu ich das dann so:</p>
<pre><code>Selectionsort&lt;int&gt; *sort = new Selectionsort&lt;int&gt;(size)
</code></pre>
<p>Wo ist mein Fehler?<br />
Vielen Dank im voraus für eure Hilfe!</p>
<p>Karlsberg_86</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2223995</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2223995</guid><dc:creator><![CDATA[Karlsberg87]]></dc:creator><pubDate>Sat, 16 Jun 2012 19:42:39 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und Templates on Sat, 16 Jun 2012 21:49:14 GMT]]></title><description><![CDATA[<p>Hi.</p>
<p>Ich glaub da fehlt ein &lt;T&gt; ...</p>
<pre><code class="language-cpp">template &lt;class T&gt; 
Selectionsort::Selectionsort(int size) : SortingAlgorithm&lt;T&gt;(size) 
{ 

}
</code></pre>
<p>Welches du bei der Basisklasse ganz richtig mit geschrieben hattest.</p>
<blockquote>
<p>Code:<br />
// Konstruktor<br />
template &lt;class T&gt;<br />
SortingAlgorithm**&lt;T&gt;**::SortingAlgorithm(int size)<br />
{<br />
}</p>
</blockquote>
<p>tommy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224034</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224034</guid><dc:creator><![CDATA[tommy_tom_tom]]></dc:creator><pubDate>Sat, 16 Jun 2012 21:49:14 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und Templates on Sun, 17 Jun 2012 12:37:25 GMT]]></title><description><![CDATA[<p>Nein, das ist es leider nicht. Sonst noch jemand mit ner Idee?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224159</guid><dc:creator><![CDATA[Karlsberg87]]></dc:creator><pubDate>Sun, 17 Jun 2012 12:37:25 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und Templates on Sun, 17 Jun 2012 12:50:40 GMT]]></title><description><![CDATA[<p>Schick doch mal die gesamte Fehlermeldung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224164</guid><dc:creator><![CDATA[tommy_tom_tom]]></dc:creator><pubDate>Sun, 17 Jun 2012 12:50:40 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und Templates on Sun, 17 Jun 2012 13:18:14 GMT]]></title><description><![CDATA[<p>Ich sehe eben, das du den Ctor:</p>
<pre><code class="language-cpp">#include &quot;selectionsort.h&quot;

// Konstruktor

template &lt;class T&gt;
Selectionsort::Selectionsort(int size) : SortingAlgorithm&lt;T&gt;(size)
{

}
</code></pre>
<p>in einem externen Sourcefile implimentiert hast. Ich meine da müsste man wohl mit export arbeiten... ich glaube aber auch gelesen zu haben, das das nur mangelhaft oder teilweise gar nicht von vielen Compilern unterstützt wird. Ist das noch so?</p>
<p>Abschnitt (v)<br />
<a href="http://www.mathematik.uni-bayreuth.de/~rbaier/lectures/c++/html/node63.html" rel="nofollow">http://www.mathematik.uni-bayreuth.de/~rbaier/lectures/c++/html/node63.html</a></p>
<p>Tommy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224172</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224172</guid><dc:creator><![CDATA[tommy_tom_tom]]></dc:creator><pubDate>Sun, 17 Jun 2012 13:18:14 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und Templates on Sun, 17 Jun 2012 14:13:38 GMT]]></title><description><![CDATA[<p>hab ich auch gelesen, aber waren relativ alte Meldungen.</p>
<p>Hier die gesamte Fehlermeldung:</p>
<pre><code>In file included from ..\QT/svn/model/sortingAlgorithm.h:17,
                 from ..\QT\svn\model\sortingAlgorithm.cpp:9:
..\QT/svn/model/selectionsort.h:17: error: expected template-name before '&lt;' token
..\QT/svn/model/selectionsort.h:17: error: expected '{' before '&lt;' token
..\QT/svn/model/selectionsort.h:17: error: expected unqualified-id before '&lt;' token
mingw32-make.exe[1]: *** [debug/sortingAlgorithm.o] Error 1
</code></pre>
<p>Heißt das, dass alle h. Dateien zusammengefasst werden müssen, die von der Klasse erben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224186</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224186</guid><dc:creator><![CDATA[Karlsberg87]]></dc:creator><pubDate>Sun, 17 Jun 2012 14:13:38 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und Templates on Sun, 17 Jun 2012 14:45:55 GMT]]></title><description><![CDATA[<p>zirkuläre includes</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224197</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224197</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sun, 17 Jun 2012 14:45:55 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und Templates on Sun, 17 Jun 2012 15:04:15 GMT]]></title><description><![CDATA[<p>Nebenbei: Vom Design her ist es recht fragwürdig, wenn Sortieralgorithmen als Klassen implementiert werden. Warum keine Funktionen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224199</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224199</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sun, 17 Jun 2012 15:04:15 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und Templates on Sun, 17 Jun 2012 15:18:42 GMT]]></title><description><![CDATA[<blockquote>
<p>Heißt das, dass alle h. Dateien zusammengefasst werden müssen, die von der Klasse erben?</p>
</blockquote>
<p>Ne, nur die Methoden der Klasse mit in ihren Header. So mach ich das -&gt; ob das so optimal ist... ich würd mich da gern etwas besseren belehren lassen...</p>
<p>Nexus schrieb:</p>
<blockquote>
<p>Nebenbei: Vom Design her ist es recht fragwürdig, wenn Sortieralgorithmen als Klassen implementiert werden. Warum keine Funktionen?</p>
</blockquote>
<p>Wird das Strategiepattern nicht auch mit unter mit Klassen umgesezt? Ist doch nicht so sehr falsch oder?<br />
<a href="http://magazin.c-plusplus.net/artikel/Einf%FChrung%20in%20Design%20Patterns" rel="nofollow">http://magazin.c-plusplus.net/artikel/Einf�hrung in Design Patterns</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224205</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224205</guid><dc:creator><![CDATA[tommy_tom_tom]]></dc:creator><pubDate>Sun, 17 Jun 2012 15:18:42 GMT</pubDate></item></channel></rss>