<?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[Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet?]]></title><description><![CDATA[<p>Was ist &quot;typename&quot;, und wie wird es verwendet?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/123028/was-ist-quot-typename-quot-und-wie-wird-es-verwendet</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 09:42:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/123028.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 12 Oct 2005 11:24:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet? on Wed, 12 Oct 2005 11:24:04 GMT]]></title><description><![CDATA[<p>Was ist &quot;typename&quot;, und wie wird es verwendet?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890485</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890485</guid><dc:creator><![CDATA[typename]]></dc:creator><pubDate>Wed, 12 Oct 2005 11:24:04 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet? on Wed, 12 Oct 2005 11:29:45 GMT]]></title><description><![CDATA[<p>Wie die Bezeichnung schon andeutet, kennzeichnet es den nachfolgenden Bezeichner als Namen eines Datentyps. Wird verwendet bei Template-Klassen, weil dort nicht immer klar ist, ob ein Datenelement oder Untertyp gemeint ist:</p>
<pre><code class="language-cpp">template&lt;typename T&gt; fkt(const T&amp; x)
{
  T::sub i; // ist T::sub ein statisches Element oder Subklasse? Complier plädiert auf Element
  typename T::sub i; // klar festgelegt als Subklasse ( z.B. class X{class sub{..}} )
}
</code></pre>
<p>(und in der Definition des Templates zeigt &quot;typename&quot; an, daß der Template-Parameter einen Datentyp darstellen soll, z.B. int, char oder eine selbstdefinierte Klasse)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890492</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890492</guid><dc:creator><![CDATA[CS]]></dc:creator><pubDate>Wed, 12 Oct 2005 11:29:45 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet? on Wed, 12 Oct 2005 11:44:33 GMT]]></title><description><![CDATA[<p>Danke! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Was bedeutet &quot;typedef typename ... T;&quot;?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890507</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890507</guid><dc:creator><![CDATA[typename]]></dc:creator><pubDate>Wed, 12 Oct 2005 11:44:33 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet? on Wed, 12 Oct 2005 11:50:56 GMT]]></title><description><![CDATA[<p>das selbe wie oben - aus der angegebenen Definition kann der Compiler nicht ableiten, ob du da von einem Typ oder einem Datenelement redest:<br />
[cpp]template&lt;typename T&gt; class X<br />
{<br />
typedef T::sub T_sub; // was verbirgt sich hinter T::sub?<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890521</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890521</guid><dc:creator><![CDATA[CS]]></dc:creator><pubDate>Wed, 12 Oct 2005 11:50:56 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet? on Wed, 12 Oct 2005 11:55:08 GMT]]></title><description><![CDATA[<p>Früher war das doch so, dass der Compiler dies zur Zeit der Template-Instantiierung / Spezialisierung erst aufgelöst hat. Warum hat man dafür &quot;typename&quot; eingeführt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890526</guid><dc:creator><![CDATA[typename]]></dc:creator><pubDate>Wed, 12 Oct 2005 11:55:08 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet? on Wed, 12 Oct 2005 11:58:37 GMT]]></title><description><![CDATA[<p>Wann früher?</p>
<p>Der Compiler kann bei der Instantiierung eventuell festlegen, welcher Typ sich hinter T::sub verbirgt, und den Code entsprechend anpassen. Aber ohne Hilfsinformationen kann er nicht prüfen, OB T::sub ein Datentyp ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890534</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890534</guid><dc:creator><![CDATA[CS]]></dc:creator><pubDate>Wed, 12 Oct 2005 11:58:37 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet? on Wed, 12 Oct 2005 12:05:28 GMT]]></title><description><![CDATA[<p>Der Compiler erzeugt zuerst einen Syntaxbaum der Template-Deklaration. Wird das Template instanziiert, werden die Template-Parameter ersetzt und dann erst wird der Code in das Programm eingefügt. Gibt es einen logischen Grund für &quot;typename&quot;?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890543</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890543</guid><dc:creator><![CDATA[typename]]></dc:creator><pubDate>Wed, 12 Oct 2005 12:05:28 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet? on Wed, 12 Oct 2005 12:09:30 GMT]]></title><description><![CDATA[<p>für den Syntaxbaum ist es unerheblich, ob du an einer Stelle ein double oder ein int stehen hast, der Unterschied zwischen dem Typ int und einer int-Variablen ist da schon erheblicher <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="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/890547</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890547</guid><dc:creator><![CDATA[CS]]></dc:creator><pubDate>Wed, 12 Oct 2005 12:09:30 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet? on Wed, 12 Oct 2005 12:21:52 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">template &lt; class T &gt; class X {
   public:
   typedef T::sub T_sub; // was verbirgt sich hinter T::sub?
};
</code></pre>
<p>führt auf ISO C++ Compilern zu einem Fehler &quot;ISO C++ forbids declaration of `sub' with no type&quot;, auf prä-ISO C++ Compilern aber nicht. Also muss man Programme, die das benutzt haben, anpassen und &quot;typedef typename&quot; schreiben. Aber warum hat man das gemacht? Wenn's früher auch ohne ging?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890560</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890560</guid><dc:creator><![CDATA[typename]]></dc:creator><pubDate>Wed, 12 Oct 2005 12:21:52 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet? on Wed, 12 Oct 2005 12:40:25 GMT]]></title><description><![CDATA[<p>Was würde denn ein prä-ISO Compiler dir erzählen, wenn du den Codeschnipsel ergänzt um:</p>
<pre><code class="language-cpp">class tester
{
public: int sub;
};

int main()
{
X&lt;tester&gt; xt;
}
</code></pre>
<p>(wenn das noch klaglos akzeptiert wird, spätestens bei einer Methode &quot;template&lt;typename T&gt; X&lt;T&gt;::t_sub X&lt;T&gt;::get_sub();&quot; dürfte es nach meinem Wissen krachen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890582</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890582</guid><dc:creator><![CDATA[CS]]></dc:creator><pubDate>Wed, 12 Oct 2005 12:40:25 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet? on Wed, 12 Oct 2005 12:45:12 GMT]]></title><description><![CDATA[<p>Abhängige Namen (dependant names) werden grundsätzlich nicht als Typnamen betrachtet - es sei denn, man benutzt das Schlüsselwort typename. Auf modernen Compilern solltest Du es immer hinschreiben müssen, während ältere Compiler das meistens durchgehen lassen, weil damals (1998) noch niemand das Schlüsselwort typename kannte und es zig-tausend Quellcodes zerbrochen hätte.</p>
<p>Das Problem ist halt, dass z.B. T::sub je nach Typ von T mal ein statisches Member ist, mal ein Typname oder sonstwas. Ich denke es dient dazu, die Bedeutung des Template-Codes zu stärken.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890584</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890584</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Wed, 12 Oct 2005 12:45:12 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist &amp;quot;typename&amp;quot;, und wie wird es verwendet? on Wed, 12 Oct 2005 12:49:58 GMT]]></title><description><![CDATA[<p>7H3 N4C3R schrieb:</p>
<blockquote>
<p>Ich denke es dient dazu, die Bedeutung des Template-Codes zu stärken.</p>
</blockquote>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890594</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890594</guid><dc:creator><![CDATA[typename]]></dc:creator><pubDate>Wed, 12 Oct 2005 12:49:58 GMT</pubDate></item></channel></rss>