<?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 VOR Deklaration?]]></title><description><![CDATA[<p>Hi,</p>
<p>Wieso kompiliert das hier?</p>
<pre><code class="language-cpp">typedef shared_ptr&lt;MyClass&gt; MyClassPtr;

class MyClass {

};
</code></pre>
<p>An der Stelle mit dem typedef ist MyClass ja noch nicht mal deklariert. Ist das gültiger Code? Wieso geht das?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/299198/typedef-vor-deklaration</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 10:48:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/299198.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 05 Feb 2012 13:02:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to typedef VOR Deklaration? on Sun, 05 Feb 2012 13:02:34 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>Wieso kompiliert das hier?</p>
<pre><code class="language-cpp">typedef shared_ptr&lt;MyClass&gt; MyClassPtr;

class MyClass {

};
</code></pre>
<p>An der Stelle mit dem typedef ist MyClass ja noch nicht mal deklariert. Ist das gültiger Code? Wieso geht das?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2177159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2177159</guid><dc:creator><![CDATA[Mariiuu]]></dc:creator><pubDate>Sun, 05 Feb 2012 13:02:34 GMT</pubDate></item><item><title><![CDATA[Reply to typedef VOR Deklaration? on Sun, 05 Feb 2012 13:12:28 GMT]]></title><description><![CDATA[<p>Hä? Bei mir funzt garnix.</p>
<pre><code class="language-cpp">#include &quot;boost/shared_ptr.hpp&quot;

typedef boost::shared_ptr&lt;MyClass&gt; MyClassPtr;

class MyClass {

};
</code></pre>
<blockquote>
<p>C(++) Saves\TEMPS\TEMP.cxx|3|error: 'MyClass' was not declared in this scope|<br />
C(++) Saves\TEMPS\TEMP.cxx|3|error: template argument 1 is invalid|<br />
C(++) Saves\TEMPS\TEMP.cxx|3|error: invalid type in declaration before ';' token|</p>
</blockquote>
<p>GCC 4.7</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2177165</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2177165</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 05 Feb 2012 13:12:28 GMT</pubDate></item><item><title><![CDATA[Reply to typedef VOR Deklaration? on Sun, 05 Feb 2012 13:12:36 GMT]]></title><description><![CDATA[<p>GCC:</p>
<pre><code class="language-cpp">./test.cpp:3:25: Fehler: »MyClass« wurde in diesem Gültigkeitsbereich nicht definiert
./test.cpp:3:32: Fehler: Templateargument 1 ist ungültig
./test.cpp:3:44: Fehler: invalid type in declaration before »;« token
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2177166</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2177166</guid><dc:creator><![CDATA[pyhax]]></dc:creator><pubDate>Sun, 05 Feb 2012 13:12:36 GMT</pubDate></item><item><title><![CDATA[Reply to typedef VOR Deklaration? on Sun, 05 Feb 2012 13:13:52 GMT]]></title><description><![CDATA[<p>Ehrlich gesagt würde es mich wundern, wenn das kompilieren soll...</p>
<p>Du brauchst zumindest eine Vorwärtsdeklaration von MyClass;</p>
<p>Aber dann funktioniert es, weil in dem shared_ptr nur Zeiger (und Referenzen) auf das Objekt<br />
verwendet werden.</p>
<p>Wie du siehst, brauchst du hier auch nicht die kompletten Objekt-Informationen:</p>
<pre><code class="language-cpp">class MyClass;

template&lt;typename T&gt;
class my_shared_ptr{
public:
	my_shared_ptr(T* ptr) : ptr(ptr){
	}
private:
	T* ptr;
};

class MyClass { 

};
</code></pre>
<p>Gruß,<br />
Xspille</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2177169</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2177169</guid><dc:creator><![CDATA[XSpille]]></dc:creator><pubDate>Sun, 05 Feb 2012 13:13:52 GMT</pubDate></item><item><title><![CDATA[Reply to typedef VOR Deklaration? on Sun, 05 Feb 2012 13:14:10 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/27772">@pyhax</a>: Was is'n das für ein Compiler, halb englisch halb deutsch? <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/2177170</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2177170</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 05 Feb 2012 13:14:10 GMT</pubDate></item><item><title><![CDATA[Reply to typedef VOR Deklaration? on Sun, 05 Feb 2012 13:18:50 GMT]]></title><description><![CDATA[<p>Hacker schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/27772">@pyhax</a>: Was is'n das für ein Compiler, halb englisch halb deutsch? <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>Ich kann es auch english machen <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>
<pre><code>[pyhax@archlinux tmp]$ LANG=&quot;en_US&quot; g++ ./test.cpp -otest -g -std=c++0x -Wall -Wextra -pedantic -Weffc++
./test.cpp:3:25: error: `MyClass' was not declared in this scope
./test.cpp:3:32: error: template argument 1 is invalid
./test.cpp:3:44: error: invalid type in declaration before `;' token
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2177175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2177175</guid><dc:creator><![CDATA[pyhax]]></dc:creator><pubDate>Sun, 05 Feb 2012 13:18:50 GMT</pubDate></item></channel></rss>