<?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[doppelte definirung]]></title><description><![CDATA[<pre><code class="language-cpp">//i.hpp
#ifndef _ICH_HPP_
#define _ICH_HPP_
class Ich{
  int a;
  Ich();
  void funk();
}Ich;
#endif

//i.cpp
#include &quot;i.hpp&quot;
Ich::Ich(): a(10){}
void Ich::funk(){
  //mach was
}
</code></pre>
<pre><code class="language-cpp">#ifndef _DU_HPP_
#define _DU_HPP_
//d.hpp
#include &quot;i.hpp&quot;
class Du{
   Du();
}
#endif

//d.hpp
#include &quot;d.hpp&quot;

Du::Du(){
  Ich.funk();
}
</code></pre>
<pre><code class="language-cpp">#include &quot;d.hpp&quot;

int main()
{

}
</code></pre>
<p>meldung:<br />
main.cxx 3: multiple definition of `Ich'</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/203775/doppelte-definirung</link><generator>RSS for Node</generator><lastBuildDate>Wed, 07 Oct 2026 19:03:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/203775.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 26 Jan 2008 12:35:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to doppelte definirung on Sat, 26 Jan 2008 12:35:56 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">//i.hpp
#ifndef _ICH_HPP_
#define _ICH_HPP_
class Ich{
  int a;
  Ich();
  void funk();
}Ich;
#endif

//i.cpp
#include &quot;i.hpp&quot;
Ich::Ich(): a(10){}
void Ich::funk(){
  //mach was
}
</code></pre>
<pre><code class="language-cpp">#ifndef _DU_HPP_
#define _DU_HPP_
//d.hpp
#include &quot;i.hpp&quot;
class Du{
   Du();
}
#endif

//d.hpp
#include &quot;d.hpp&quot;

Du::Du(){
  Ich.funk();
}
</code></pre>
<pre><code class="language-cpp">#include &quot;d.hpp&quot;

int main()
{

}
</code></pre>
<p>meldung:<br />
main.cxx 3: multiple definition of `Ich'</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1443949</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1443949</guid><dc:creator><![CDATA[ichich]]></dc:creator><pubDate>Sat, 26 Jan 2008 12:35:56 GMT</pubDate></item><item><title><![CDATA[Reply to doppelte definirung on Sat, 26 Jan 2008 13:07:44 GMT]]></title><description><![CDATA[<p>Du definierst in „i.hpp“ eine Instanz Deiner Klasse 'Ich' (mit demselben Namen). Deine HPP-Datei wird aber in mehrere Code-Einheiten eingebunden, wodurch die multiple Instanzierung entsteht.</p>
<p>Einfache Lösung: deklarier 'Ich' im Header lediglich (d.h. als 'extern' markieren' und definier's in der „i.cpp“-Datei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1443959</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1443959</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Sat, 26 Jan 2008 13:07:44 GMT</pubDate></item><item><title><![CDATA[Reply to doppelte definirung on Sat, 26 Jan 2008 13:17:51 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">//i.hpp
#ifndef _ICH_HPP_
#define _ICH_HPP_
class Ich{
  int a;
  Ich();
  void funk();
};
#endif

//i.cpp
#include &quot;i.hpp&quot;

extern Ich Ich;

Ich::Ich(): a(10){}
void Ich::funk(){
  //mach was
}
</code></pre>
<pre><code class="language-cpp">#ifndef _DU_HPP_
#define _DU_HPP_
//d.hpp
#include &quot;i.hpp&quot;
class Du{
   Du();
}
#endif

//d.hpp
#include &quot;d.hpp&quot;

Du::Du(){
  Ich.funk();  //hier
}
</code></pre>
<p>jetzt meldet er das er Ich nicht finden kann</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1443966</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1443966</guid><dc:creator><![CDATA[ichich]]></dc:creator><pubDate>Sat, 26 Jan 2008 13:17:51 GMT</pubDate></item><item><title><![CDATA[Reply to doppelte definirung on Sat, 26 Jan 2008 13:21:09 GMT]]></title><description><![CDATA[<p>Du verwechselst Deklaration und Definition. Die Deklaration muss in den Header, die Definition in die cpp-Datei:</p>
<pre><code class="language-cpp">// i.hpp

#ifndef _ICH_HPP_
#define _ICH_HPP_
class Ich{
  int a;
  Ich();
  void funk();
};

extern Ich Ich;

#endif
</code></pre>
<pre><code class="language-cpp">// i.cpp

#include &quot;i.hpp&quot;

Ich Ich;

// … der Rest
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1443968</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1443968</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Sat, 26 Jan 2008 13:21:09 GMT</pubDate></item><item><title><![CDATA[Reply to doppelte definirung on Sat, 26 Jan 2008 13:26:29 GMT]]></title><description><![CDATA[<p>es klappt thx ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1443971</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1443971</guid><dc:creator><![CDATA[ichich]]></dc:creator><pubDate>Sat, 26 Jan 2008 13:26:29 GMT</pubDate></item><item><title><![CDATA[Reply to doppelte definirung on Sat, 26 Jan 2008 13:27:53 GMT]]></title><description><![CDATA[<p>Nich was: nenn die globale Variable nicht genauso wie den Typ, das gibt Probleme. Und verzichte am besten ganz auf die globale Variable, das gibt Ärger mit der Initialisierungsreihenfolge der Objekte etc. Besser ist es, eine globale Funktion zu verwenden, die eine statisches Instanz zurückgibt, oder die Klasse als Singleton zu implementieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1443975</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1443975</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Sat, 26 Jan 2008 13:27:53 GMT</pubDate></item></channel></rss>