<?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[typedef als Rückgabewert]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich möchte folgendes machen, allerdings gibt mir der Compiler immer folgende Fehlermeldung in der cpp-Datei:<br />
line 7: error: expected constructor, destructor, or type conversion before &quot;myclass&quot;</p>
<p>hier mein h-File:</p>
<pre><code class="language-cpp">#include &lt;vector&gt;

template &lt;class T&gt;
class myclass
{
public:
    typedef typename std::vector&lt;T&gt;::iterator myiterator;
    myclass();
    ~myclass();
    myiterator getIterator();
private:
    std::vector&lt;T&gt; v;
};
</code></pre>
<p>und hier mein cpp-File:</p>
<pre><code class="language-cpp">#include &quot;myclass.h&quot;

template &lt;class T&gt; myclass&lt;T&gt;::myclass() : v() { }

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

template &lt;class T&gt; myiterator myclass&lt;T&gt;::getIterator()
{
    return v.begin();
}
</code></pre>
<p>Ich weiss einfach nicht was ich falsch mache. Ich habe auch gedacht, dass das vielleicht nicht geht wegen den templates aber ich habe auch schon ein typedef mit int versucht mit dem gleichen resultat. Wenn ich den per typedef definierten typ als parameter angebe funktioniert es ja auch, wieso kann ich ihn dann nicht auch als Rückgabewert nehmen?<br />
Vielen Dank schonmal für eure Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/217198/typedef-als-rückgabewert</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 21:06:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/217198.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 04 Jul 2008 11:46:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to typedef als Rückgabewert on Fri, 04 Jul 2008 11:46:58 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich möchte folgendes machen, allerdings gibt mir der Compiler immer folgende Fehlermeldung in der cpp-Datei:<br />
line 7: error: expected constructor, destructor, or type conversion before &quot;myclass&quot;</p>
<p>hier mein h-File:</p>
<pre><code class="language-cpp">#include &lt;vector&gt;

template &lt;class T&gt;
class myclass
{
public:
    typedef typename std::vector&lt;T&gt;::iterator myiterator;
    myclass();
    ~myclass();
    myiterator getIterator();
private:
    std::vector&lt;T&gt; v;
};
</code></pre>
<p>und hier mein cpp-File:</p>
<pre><code class="language-cpp">#include &quot;myclass.h&quot;

template &lt;class T&gt; myclass&lt;T&gt;::myclass() : v() { }

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

template &lt;class T&gt; myiterator myclass&lt;T&gt;::getIterator()
{
    return v.begin();
}
</code></pre>
<p>Ich weiss einfach nicht was ich falsch mache. Ich habe auch gedacht, dass das vielleicht nicht geht wegen den templates aber ich habe auch schon ein typedef mit int versucht mit dem gleichen resultat. Wenn ich den per typedef definierten typ als parameter angebe funktioniert es ja auch, wieso kann ich ihn dann nicht auch als Rückgabewert nehmen?<br />
Vielen Dank schonmal für eure Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1540954</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1540954</guid><dc:creator><![CDATA[Schamaz]]></dc:creator><pubDate>Fri, 04 Jul 2008 11:46:58 GMT</pubDate></item><item><title><![CDATA[Reply to typedef als Rückgabewert on Fri, 04 Jul 2008 11:50:14 GMT]]></title><description><![CDATA[<p>1. Templates können (normalerweise) nicht wie üblich in Dekl. und Impl. getrennt werden. (suche mal zu dem Thema).<br />
2. Der Rückgabewert ist nicht mehr im Klassenscope bei der Definition. Da aber dein typedef innerhalb der Klasse ist, wird er nicht gefunden.</p>
<p>Simon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1540958</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1540958</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Fri, 04 Jul 2008 11:50:14 GMT</pubDate></item><item><title><![CDATA[Reply to typedef als Rückgabewert on Fri, 04 Jul 2008 11:50:48 GMT]]></title><description><![CDATA[<p>nimm mal das typename weg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1540960</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1540960</guid><dc:creator><![CDATA[DocJunioR]]></dc:creator><pubDate>Fri, 04 Jul 2008 11:50:48 GMT</pubDate></item><item><title><![CDATA[Reply to typedef als Rückgabewert on Fri, 04 Jul 2008 13:23:19 GMT]]></title><description><![CDATA[<p>DocJunioR schrieb:</p>
<blockquote>
<p>nimm mal das typename weg</p>
</blockquote>
<p>Nein, das wird da benötigt. Den Rest hat Simon bereits gesagt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1541033</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1541033</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Fri, 04 Jul 2008 13:23:19 GMT</pubDate></item></channel></rss>