<?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 Erben]]></title><description><![CDATA[<p>Hey ich habe vollgendes Problem:<br />
Ich habe eine template Klasse mit virtuellen funktionen</p>
<pre><code class="language-cpp">//parent.h
template &lt;class T&gt;
class parent
{
private:
   T m_data;
pubilc:
   parent();
   ~parent();
   virtual void func();
   T getData();
};

//parent.cpp
#include &quot;parent.h&quot;
template&lt;class T&gt;
T parent&lt;T&gt;::getData(){...}
</code></pre>
<p>Jetzt erbe ich von parent:</p>
<pre><code class="language-cpp">//child.h
template &lt;class T&gt;
class child : parent&lt;T&gt;
{
private:
   ...
public:
   child();
   ~child();
   void func();
};

//child.cpp
#include &quot;child.h&quot;
template&lt;class T&gt;
child&lt;T&gt;::child()
:parent&lt;T&gt;(){...}

template&lt;class T&gt;
child&lt;T&gt;::~child(){...}

template&lt;class T&gt;
void child&lt;T&gt;::func(){...}
</code></pre>
<p>Egal was ich jetzt an der child.cpp Datei änder, der Compiler läuft immer ohne Fehler durch. Es scheint als ob diese vollständig ignoriert wird, selbst Löschen erzeugt keinen Compiler fehler.<br />
Wenn ich die Vererbung raushaue scheint alles korrekt zu laufen <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>
<p>Ich nutzte VS2012, aber auch bei VS2010 tritt das Problem auf.</p>
<p>Mfg. Matyro</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/306577/template-erben</link><generator>RSS for Node</generator><lastBuildDate>Fri, 07 Aug 2026 16:40:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/306577.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 01 Aug 2012 15:42:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 15:42:27 GMT]]></title><description><![CDATA[<p>Hey ich habe vollgendes Problem:<br />
Ich habe eine template Klasse mit virtuellen funktionen</p>
<pre><code class="language-cpp">//parent.h
template &lt;class T&gt;
class parent
{
private:
   T m_data;
pubilc:
   parent();
   ~parent();
   virtual void func();
   T getData();
};

//parent.cpp
#include &quot;parent.h&quot;
template&lt;class T&gt;
T parent&lt;T&gt;::getData(){...}
</code></pre>
<p>Jetzt erbe ich von parent:</p>
<pre><code class="language-cpp">//child.h
template &lt;class T&gt;
class child : parent&lt;T&gt;
{
private:
   ...
public:
   child();
   ~child();
   void func();
};

//child.cpp
#include &quot;child.h&quot;
template&lt;class T&gt;
child&lt;T&gt;::child()
:parent&lt;T&gt;(){...}

template&lt;class T&gt;
child&lt;T&gt;::~child(){...}

template&lt;class T&gt;
void child&lt;T&gt;::func(){...}
</code></pre>
<p>Egal was ich jetzt an der child.cpp Datei änder, der Compiler läuft immer ohne Fehler durch. Es scheint als ob diese vollständig ignoriert wird, selbst Löschen erzeugt keinen Compiler fehler.<br />
Wenn ich die Vererbung raushaue scheint alles korrekt zu laufen <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>
<p>Ich nutzte VS2012, aber auch bei VS2010 tritt das Problem auf.</p>
<p>Mfg. Matyro</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237699</guid><dc:creator><![CDATA[Matyro]]></dc:creator><pubDate>Wed, 01 Aug 2012 15:42:27 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 15:54:57 GMT]]></title><description><![CDATA[<p>Du darfst nicht Templates in Source und Header aufteilen.<br />
Ausserdem: Wird denn ueberhaupt eine Spezialisierung generiert? Also instanziierst du wenigstens ein Objekt vom Typ <code>child&lt;..&gt;</code> ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237705</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 01 Aug 2012 15:54:57 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 15:59:09 GMT]]></title><description><![CDATA[<p>Hast du die &quot;child.cpp&quot; überhaupt deinem Projekt hinzugefügt?<br />
Aber selbst dann wäre es vermutlich falsch, denn Templates sollten immer im Header komplett definiert sein (außer du benutzt das Template nur in dieser Source-Datei), s.a. <a href="http://www.c-plusplus.net/forum/39467" rel="nofollow">Template in Header- und Source-Datei aufteilen</a></p>
<p>P.S.</p>
<blockquote>
<p>vollgendes</p>
</blockquote>
<p>Ist das jetzt die neue Rechtschreibung, OMG!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237708</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237708</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Wed, 01 Aug 2012 15:59:09 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 16:05:50 GMT]]></title><description><![CDATA[<p>Nein aktuell instanziere ich noch kein Objekt von Child,</p>
<p>bei anderen Klassen scheint aber das splitten zu klappen...</p>
<blockquote>
<p>Ist das jetzt die neue Rechtschreibung, OMG!</p>
</blockquote>
<p>Nein, aber eine angeborene Rechtschreibschwäche <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="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237710</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237710</guid><dc:creator><![CDATA[Matyro]]></dc:creator><pubDate>Wed, 01 Aug 2012 16:05:50 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 16:41:52 GMT]]></title><description><![CDATA[<p>das ist aber ganz einfach. Folgendes kommt von folgen, weil etwas, was man als &quot;Folgendes&quot; bezeichnet auf das, was man gerade geschrieben hat, folgt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237724</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237724</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Wed, 01 Aug 2012 16:41:52 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 16:54:32 GMT]]></title><description><![CDATA[<p>Eisflamme schrieb:</p>
<blockquote>
<p>Folgendes kommt von folgen, weil etwas, was man als &quot;Folgendes&quot; bezeichnet auf das, was man gerade geschrieben hat, folgt.</p>
</blockquote>
<p>Ich kann dir nicht ganz folgen.</p>
<p><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>
]]></description><link>https://www.c-plusplus.net/forum/post/2237728</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237728</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 01 Aug 2012 16:54:32 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 22:12:25 GMT]]></title><description><![CDATA[<p>Leider ist das für mich nicht ganz so einfach..<br />
naja back to topic</p>
<p>Ich habe jetzt alles in die Header geschaufelt und den Rest gelöscht.<br />
Leider kann ich in die Funktionsrümpfe nach wie vor alles reinpacken was ich möchte ohne das der Compiler fehler wirft.</p>
<p>Hier mal direkt als Bsp. aus meiner Child.h, der Build läuft erfolgreich durch!</p>
<pre><code class="language-cpp">~tcp(void)
	{ a-sd  //&lt;-- FEHLER!!
		m_cs.lock();
		close();
		m_cs.unlock();
	}
</code></pre>
<p>Wichtig zu erwähnen ist vielleicht noch das es sich bei dem Projekt um eine statische .lib handelt.</p>
<p>Mfg. Matyro</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237776</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237776</guid><dc:creator><![CDATA[Matyro]]></dc:creator><pubDate>Wed, 01 Aug 2012 22:12:25 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 22:14:44 GMT]]></title><description><![CDATA[<p>Matyro schrieb:</p>
<blockquote>
<p>Hier mal direkt als Bsp. aus meiner Child.h, der Build läuft erfolgreich durch!</p>
<pre><code class="language-cpp">~tcp(void)
	{ a-sd  //&lt;-- FEHLER!!
		m_cs.lock();
		close();
		m_cs.unlock();
	}
</code></pre>
</blockquote>
<p>Das ist komisch. Sicher, dass der Header in einer deiner Uebersetzungseinheiten eingebunden wird? Und das diese zum Projekt hinzugefuegt worden sind?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237777</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237777</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 01 Aug 2012 22:14:44 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 22:40:44 GMT]]></title><description><![CDATA[<p>Ich wüsste nicht wie ich das kontrollieren könnte,<br />
da ich aber nichts explizit ausgeschlossen habe sollte es eigentlich enthalten sein...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237782</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237782</guid><dc:creator><![CDATA[Matyro]]></dc:creator><pubDate>Wed, 01 Aug 2012 22:40:44 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 22:51:59 GMT]]></title><description><![CDATA[<p>Matyro schrieb:</p>
<blockquote>
<p>Ich wüsste nicht wie ich das kontrollieren könnte</p>
</blockquote>
<pre><code class="language-cpp">#include &lt;HEADER&gt;
</code></pre>
<blockquote>
<p>da ich aber nichts explizit ausgeschlossen habe sollte es eigentlich enthalten sein...</p>
</blockquote>
<p>Wenn ich verstehe was du meinst, hast du es falsch gemacht. Denn du musst meistens alles explizit einbinden.</p>
<p>Edit: Siehe unten, obiges ist fuer dich irrelevant</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237784</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237784</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 01 Aug 2012 22:51:59 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 22:46:34 GMT]]></title><description><![CDATA[<p>Es handelt sich ja um eine lib und damit um eine Sammlung von Klassen,<br />
ich wüsste jetzt gerade nicht wo ich den entsprechenden #include hinsetzen sollte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237785</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237785</guid><dc:creator><![CDATA[Matyro]]></dc:creator><pubDate>Wed, 01 Aug 2012 22:46:34 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 22:52:24 GMT]]></title><description><![CDATA[<p><strong>du kannst Templates nicht in Libs packen.</strong> Das geht nicht. <strong>Sie muessen immer in den Header.</strong></p>
<p>Ich hab uebersehen, dass du die in eine lib packen willst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237787</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237787</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 01 Aug 2012 22:52:24 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 22:58:54 GMT]]></title><description><![CDATA[<p>Ok, sie stehen ja im Klassenheader, nur das die Klassen ursprünglich teil einer lib sein sollte...</p>
<p>Das Problem habe ich jetzt verstanden, vielen Dank.</p>
<p>VC++ überspringt einfach alles wo template drin steht (ohne warning) beim erstellen der .lib, deswegen wurden auch keine Fehler regestriert.<br />
Erst beim einbinden der header (mit template) in eine ausführbare Anwendung wurden sie mit compiliert und die entsprechenden Fehler erkannt.</p>
<p>Mfg. Matyro</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237790</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237790</guid><dc:creator><![CDATA[Matyro]]></dc:creator><pubDate>Wed, 01 Aug 2012 22:58:54 GMT</pubDate></item><item><title><![CDATA[Reply to Template Erben on Wed, 01 Aug 2012 23:05:21 GMT]]></title><description><![CDATA[<p>Matyro schrieb:</p>
<blockquote>
<p>VC++ überspringt einfach alles wo template drin steht</p>
</blockquote>
<p>lol.<br />
Wenn das der Fall ist, sag ich nur:<br />
VC++ ist so beschissen. Hol dir GCC.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2237792</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2237792</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 01 Aug 2012 23:05:21 GMT</pubDate></item></channel></rss>