<?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[Problem mit Template Funktion]]></title><description><![CDATA[<p>Hi!<br />
Ich habe ein Problem mit Template Funktionen in einer Klasse ... Habe noch kaum mit templates gearbeitet und versteh den Fehler nicht. Wenn ich die Funktionen nicht in der Klasse definiere dann funktioniert der Code. Schon mal vielen Dank,</p>
<p>Max</p>
<pre><code>template&lt;typename Type, unsigned int Cellsize&gt;
class Data
{
...
};
class Writer
{
	...
	template&lt; typename T &gt;
	std::string TypeDescription() 
	{ ... };
	template&lt;&gt;
	std::string TypeDescription&lt;double&gt;()
	{
		return std::string(&quot;double&quot;);
	};

	template&lt; typename Type, unsigned int Cellsize &gt;
	inline void WriteField( const Data&lt;Type,Cellsize&gt; &amp;d)
	{
		cout&lt;&lt;TypeDescription&lt;Type&gt;();
	};
};

int main()
{
	Data&lt;double,1&gt; test;
	Writer write;
	write.WriteField(test);
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/213549/problem-mit-template-funktion</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 06:26:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/213549.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 19 May 2008 07:53:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit Template Funktion on Mon, 19 May 2008 07:53:34 GMT]]></title><description><![CDATA[<p>Hi!<br />
Ich habe ein Problem mit Template Funktionen in einer Klasse ... Habe noch kaum mit templates gearbeitet und versteh den Fehler nicht. Wenn ich die Funktionen nicht in der Klasse definiere dann funktioniert der Code. Schon mal vielen Dank,</p>
<p>Max</p>
<pre><code>template&lt;typename Type, unsigned int Cellsize&gt;
class Data
{
...
};
class Writer
{
	...
	template&lt; typename T &gt;
	std::string TypeDescription() 
	{ ... };
	template&lt;&gt;
	std::string TypeDescription&lt;double&gt;()
	{
		return std::string(&quot;double&quot;);
	};

	template&lt; typename Type, unsigned int Cellsize &gt;
	inline void WriteField( const Data&lt;Type,Cellsize&gt; &amp;d)
	{
		cout&lt;&lt;TypeDescription&lt;Type&gt;();
	};
};

int main()
{
	Data&lt;double,1&gt; test;
	Writer write;
	write.WriteField(test);
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1511987</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511987</guid><dc:creator><![CDATA[max1234]]></dc:creator><pubDate>Mon, 19 May 2008 07:53:34 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Template Funktion on Mon, 19 May 2008 08:00:35 GMT]]></title><description><![CDATA[<p>max1234 schrieb:</p>
<blockquote>
<p>versteh den Fehler nicht.</p>
</blockquote>
<p>Welchen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511992</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511992</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Mon, 19 May 2008 08:00:35 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Template Funktion on Mon, 19 May 2008 08:45:56 GMT]]></title><description><![CDATA[<pre><code>error C2275: &quot;Type&quot; : Ungültige Verwendung dieses Typs als Ausdruck 
Siehe Deklaration von 'Type' 
Siehe Verweis auf Instantiierung der kompilierten Funktionsvorlage 'void __thiscall Writer::WriteField(const class Data &amp;)' 

error C2059: Syntaxfehler : ')' 
Siehe Verweis auf Instantiierung der kompilierten Funktionsvorlage 'void __thiscall Writer::WriteField(const class Data &amp;)'

Fehler beim Ausführen von cl.exe.
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1512024</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512024</guid><dc:creator><![CDATA[Max1234]]></dc:creator><pubDate>Mon, 19 May 2008 08:45:56 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Template Funktion on Mon, 19 May 2008 09:14:46 GMT]]></title><description><![CDATA[<p>Explizite Spezialisierungen von Membertemplates müssen im Namensraum, der die jeweilige Klasse umgibt deklariert werden, nicht in der Klasse selbst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512053</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512053</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 19 May 2008 09:14:46 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Template Funktion on Mon, 19 May 2008 10:04:52 GMT]]></title><description><![CDATA[<p>Danke. Aber ich mach immer noch irgendwas falsch. Jetzt bekomme ich den Fehler<br />
fatal error C1001: INTERNER COMPILER- FEHLER <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>
<pre><code>namespace temp {
template&lt;typename Type, unsigned int Cellsize&gt; 
class Data 
{ 
... 
}; 
class Writer 
{ 
    ... 
    template&lt; typename T &gt; 
    std::string TypeDescription() 
    { ... }; 

    template&lt; typename Type, unsigned int Cellsize &gt; 
    inline void WriteField( const Data&lt;Type,Cellsize&gt; &amp;d) 
    { 
        cout&lt;&lt;TypeDescription&lt;Type&gt;(); 
    }; 
}; 

template&lt;&gt; 
    std::string Writer::TypeDescription&lt;double&gt;() 
    { 
        return std::string(&quot;double&quot;); 
    };

} //namespace temp

int main() 
{ 
    temp::Data&lt;double,1&gt; test; 
    temp::Writer write; 
    write.WriteField(test); 
    return 0; 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1512094</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512094</guid><dc:creator><![CDATA[Max1234]]></dc:creator><pubDate>Mon, 19 May 2008 10:04:52 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Template Funktion on Mon, 19 May 2008 10:18:12 GMT]]></title><description><![CDATA[<p>Zeig den Code mal exakt so wie du den Compiler fütterst. Welcher Compiler wird eingesetzt?<br />
Hinter geschweifte Klammern, die Funktionsdefinitionen abschließen, gehört kein Komma.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512107</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512107</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 19 May 2008 10:18:12 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Template Funktion on Mon, 19 May 2008 10:41:30 GMT]]></title><description><![CDATA[<p>Ich benutze VC++6.0</p>
<p>Das war schon fast der ganze code...</p>
<pre><code>typedef double Real;

using namespace std;

namespace test{
template&lt;typename Type, unsigned int Cellsize&gt;
class Data
{
};

class Writer
{
	public:
		Writer();
		~Writer();
		template&lt; typename Type &gt;
			std::string TypeDescription() 
		{
			cout&lt;&lt;(&quot;Error in Writer::TypeDescription(): Unknown Datatype &quot;);
			return (&quot; &quot;);
		}

		template&lt; typename Type, unsigned int Cellsize &gt;
			inline void WriteField(	const Data&lt;Type,Cellsize&gt; &amp;d)
		{
			cout&lt;&lt;TypeDescription&lt;Type&gt;(); 
		}
	private:
};

template&lt;&gt;
std::string Writer::TypeDescription&lt;Real&gt;()
{
	return std::string(&quot;double&quot;);
}
}

int main()
{
	test::Data&lt;Real,1&gt; hallo;
	test::Writer write;
	write.WriteField(hallo);
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1512120</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512120</guid><dc:creator><![CDATA[Max1234]]></dc:creator><pubDate>Mon, 19 May 2008 10:41:30 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Template Funktion on Mon, 19 May 2008 11:19:58 GMT]]></title><description><![CDATA[<p>Max1234 schrieb:</p>
<blockquote>
<p>Ich benutze VC++6.0</p>
</blockquote>
<p>Das wird der Grund sein. Ich empfehle ein Update auf die neueste Version, VC6 ist einfach zu fehlerhaft.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512164</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Mon, 19 May 2008 11:19:58 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Template Funktion on Mon, 19 May 2008 11:22:23 GMT]]></title><description><![CDATA[<p>Konrad Rudolph schrieb:</p>
<blockquote>
<p>Max1234 schrieb:</p>
<blockquote>
<p>Ich benutze VC++6.0</p>
</blockquote>
<p>Das wird der Grund sein. Ich empfehle ein Update auf die neueste Version, VC6 ist einfach zu fehlerhaft.</p>
</blockquote>
<p>Genau, würde ich auch empfehlen. VC++08 funktioniert es. Afaik haben älteren Compiler ja noch Probleme mit Templates/ Spezialisierung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512166</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512166</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 19 May 2008 11:22:23 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Template Funktion on Mon, 19 May 2008 11:25:43 GMT]]></title><description><![CDATA[<p>.. da hätt ich lange suchen können <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> Jetz gehts...</p>
<p>Danke nochmal!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512168</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512168</guid><dc:creator><![CDATA[Max1234]]></dc:creator><pubDate>Mon, 19 May 2008 11:25:43 GMT</pubDate></item></channel></rss>