<?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 typename erforderlich!?]]></title><description><![CDATA[<p>Hallo!</p>
<pre><code>template&lt;typename Type, typename Allocator = std::allocator&lt;Type&gt; &gt;
class CSaveVector : public std::vector&lt;Type, Allocator&gt; {
public:
 typedef std::vector&lt;Type, Allocator&gt; base_type;
 typedef CSaveVector&lt;Type, Allocator&gt; my_type;
 typedef base_type::size_type size_type; 
 //Fehler: vor »CSaveVector&lt;Type, Allocator&gt;::base_type::size_type« ist »typename« erforderlich, da »CSaveVector&lt;Type, Allocator&gt;::base_type« ein abhängiger Gültigkeitsbereich ist
 ...
};
</code></pre>
<p>Kann mir bitte einer die Fehlermeldung erklären? (für Anfänger bitte)<br />
- Warum ist da typename erforderlich?<br />
- Was ist da ein abhängiger Gültigkeitsbereich? (ist doch nur eine Deklaration)<br />
- Wie soll es laut Compiler richtig aussehen?</p>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/317545/template-typename-erforderlich</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Jul 2026 15:27:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/317545.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 12 Jun 2013 11:10:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Template typename erforderlich!? on Wed, 12 Jun 2013 11:10:00 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<pre><code>template&lt;typename Type, typename Allocator = std::allocator&lt;Type&gt; &gt;
class CSaveVector : public std::vector&lt;Type, Allocator&gt; {
public:
 typedef std::vector&lt;Type, Allocator&gt; base_type;
 typedef CSaveVector&lt;Type, Allocator&gt; my_type;
 typedef base_type::size_type size_type; 
 //Fehler: vor »CSaveVector&lt;Type, Allocator&gt;::base_type::size_type« ist »typename« erforderlich, da »CSaveVector&lt;Type, Allocator&gt;::base_type« ein abhängiger Gültigkeitsbereich ist
 ...
};
</code></pre>
<p>Kann mir bitte einer die Fehlermeldung erklären? (für Anfänger bitte)<br />
- Warum ist da typename erforderlich?<br />
- Was ist da ein abhängiger Gültigkeitsbereich? (ist doch nur eine Deklaration)<br />
- Wie soll es laut Compiler richtig aussehen?</p>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2330511</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330511</guid><dc:creator><![CDATA[xi.xi]]></dc:creator><pubDate>Wed, 12 Jun 2013 11:10:00 GMT</pubDate></item><item><title><![CDATA[Reply to Template typename erforderlich!? on Wed, 12 Jun 2013 11:14:53 GMT]]></title><description><![CDATA[<p><a href="http://pages.cs.wisc.edu/~driscoll/typename.html" rel="nofollow">http://pages.cs.wisc.edu/~driscoll/typename.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2330515</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330515</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 12 Jun 2013 11:14:53 GMT</pubDate></item><item><title><![CDATA[Reply to Template typename erforderlich!? on Wed, 12 Jun 2013 11:21:09 GMT]]></title><description><![CDATA[<blockquote>
<p>- Warum ist da typename erforderlich?</p>
</blockquote>
<p>Weil der Compiler wissen muss, dass <code>base_type::size_type</code> überhaupt ein Typ ist. <code>typename</code> ist ja ziemlich selbsterklärend <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>
<blockquote>
<p>- Was ist da ein abhängiger Gültigkeitsbereich? (ist doch nur eine Deklaration)</p>
</blockquote>
<p>Ein dependent name ist ein Name, der irgendwie von einem Template-Parameter (bzw. Argument) abhängt. &quot;Abhängiger Gültigkeitsbereich&quot; heißt, dass der Scope <code>CSaveVector&lt;Type, Allocator&gt;::base_type</code> in der Definition von <code>CSaveVector</code> von den Template-Parametern abhängt - nämlich von Type und Allocator:</p>
<pre><code>typedef std::vector&lt;Type, Allocator&gt; base_type;
</code></pre>
<blockquote>
<p>- Wie soll es laut Compiler richtig aussehen?</p>
</blockquote>
<pre><code>typedef typename base_type::size_type size_type;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2330520</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330520</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 12 Jun 2013 11:21:09 GMT</pubDate></item><item><title><![CDATA[Reply to Template typename erforderlich!? on Wed, 12 Jun 2013 11:27:35 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p><a href="http://pages.cs.wisc.edu/~driscoll/typename.html" rel="nofollow">http://pages.cs.wisc.edu/~driscoll/typename.html</a></p>
</blockquote>
<p>Gute Seite, die erklärt alles was ich auch gesagt habe. Nur das:</p>
<blockquote>
<p>typename is prohibited in each of the following scenarios:<br />
Outside of a template definition.</p>
</blockquote>
<p>Ich kann auch</p>
<pre><code>int main()
{
    typename std::string str;
}
</code></pre>
<p>schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2330522</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330522</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Wed, 12 Jun 2013 11:27:35 GMT</pubDate></item><item><title><![CDATA[Reply to Template typename erforderlich!? on Wed, 12 Jun 2013 11:30:32 GMT]]></title><description><![CDATA[<p>Super schnell! Danke !!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2330525</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330525</guid><dc:creator><![CDATA[xi.xi]]></dc:creator><pubDate>Wed, 12 Jun 2013 11:30:32 GMT</pubDate></item><item><title><![CDATA[Reply to Template typename erforderlich!? on Wed, 12 Jun 2013 11:31:57 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<p>SeppJ schrieb:</p>
<blockquote>
<p><a href="http://pages.cs.wisc.edu/~driscoll/typename.html" rel="nofollow">http://pages.cs.wisc.edu/~driscoll/typename.html</a></p>
</blockquote>
<p>Gute Seite, die erklärt alles was ich auch gesagt habe. Nur das:</p>
<blockquote>
<p>typename is prohibited in each of the following scenarios:<br />
Outside of a template definition.</p>
</blockquote>
<p>Ich kann auch</p>
<pre><code>int main()
{
    typename std::string str;
}
</code></pre>
<p>schreiben.</p>
</blockquote>
<p>Da steht auch gleich am Anfang:</p>
<blockquote>
<p>Note: This page is correct (AFAIK) for C++98/03. The rules have been loosened in C++11.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2330526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330526</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Wed, 12 Jun 2013 11:31:57 GMT</pubDate></item><item><title><![CDATA[Reply to Template typename erforderlich!? on Wed, 12 Jun 2013 11:41:14 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<p>SeppJ schrieb:</p>
<blockquote>
<p><a href="http://pages.cs.wisc.edu/~driscoll/typename.html" rel="nofollow">http://pages.cs.wisc.edu/~driscoll/typename.html</a></p>
</blockquote>
<p>Gute Seite, die erklärt alles was ich auch gesagt habe. Nur das:</p>
<blockquote>
<p>typename is prohibited in each of the following scenarios:<br />
Outside of a template definition.</p>
</blockquote>
<p>Ich kann auch</p>
<pre><code>int main()
{
    typename std::string str;
}
</code></pre>
<p>schreiben.</p>
</blockquote>
<p>Das war mal richtig so. In meinem alten Draft des C++-Standards gibt es einen gestrichenen Paragraphen, der dies verbietet.</p>
<p>edit: Zu spät. Dafür gibt's ein Zitat des gestrichenen Absatzes 14.6-5:</p>
<blockquote>
<p>The keyword typename shall only be used in template declarations and definitions, including in the return type of a<br />
function template or member function template, in the return type for the definition of a member function of a class tem-<br />
plate or of a class nested within a class template, and in the type-specifier for the definition of a static member of a class<br />
template or of a class nested within a class template. The keyword typename shall be applied only to qualified names,<br />
but those names need not be dependent. The keyword typename shall be used only in contexts in which dependent<br />
names can be used. This includes template declarations and definitions but excludes explicit specialization declarations<br />
and explicit instantiation declarations.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2330528</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330528</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 12 Jun 2013 11:41:14 GMT</pubDate></item></channel></rss>