<?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[globale instanzen &#x2F; include - Problem]]></title><description><![CDATA[<p>Hallo,<br />
hoffentlich kann mir jemand von euch hier helfen.<br />
Mein (Anfänger-) Problem ist, dass ich gerne globale Instanzen (log_log und log_debug) einer Klasse (Log) hätte. Wenn ich u.a. Code verwende bekomme ich die Fehlermeldung &quot;multiple definition&quot; für log_log und log_debug, jedoch an sinnlosen stellen in &quot;log.cpp&quot; und &quot;tis.cpp&quot;. Sind die &quot;#ifndef&quot; nicht dazu da, das zu verhindern?</p>
<p>Danke für jede Antwort.</p>
<p>Viele Grüße</p>
<p>&quot;log.hpp&quot;</p>
<pre><code class="language-cpp">#ifndef LOG_HPP_
#define LOG_HPP_
//...
class Log{
	public:
		Log();
		~Log();
		void open(std::string logname);
		void close();
		void put(std::string message);
		void clean();
	private:
		std::string filename;
};
Log log_log;
Log log_debug;
//...
#endif /*LOG_HPP_*/
</code></pre>
<p>&quot;tis.hpp&quot;</p>
<pre><code class="language-cpp">#ifndef TIS_HPP_
#define TIS_HPP_
...
#include &quot;log.hpp&quot;
...
#endif /*TISIM_HPP_*/
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/163545/globale-instanzen-include-problem</link><generator>RSS for Node</generator><lastBuildDate>Sun, 13 Sep 2026 03:38:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/163545.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 30 Oct 2006 18:19:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to globale instanzen &#x2F; include - Problem on Mon, 30 Oct 2006 18:19:43 GMT]]></title><description><![CDATA[<p>Hallo,<br />
hoffentlich kann mir jemand von euch hier helfen.<br />
Mein (Anfänger-) Problem ist, dass ich gerne globale Instanzen (log_log und log_debug) einer Klasse (Log) hätte. Wenn ich u.a. Code verwende bekomme ich die Fehlermeldung &quot;multiple definition&quot; für log_log und log_debug, jedoch an sinnlosen stellen in &quot;log.cpp&quot; und &quot;tis.cpp&quot;. Sind die &quot;#ifndef&quot; nicht dazu da, das zu verhindern?</p>
<p>Danke für jede Antwort.</p>
<p>Viele Grüße</p>
<p>&quot;log.hpp&quot;</p>
<pre><code class="language-cpp">#ifndef LOG_HPP_
#define LOG_HPP_
//...
class Log{
	public:
		Log();
		~Log();
		void open(std::string logname);
		void close();
		void put(std::string message);
		void clean();
	private:
		std::string filename;
};
Log log_log;
Log log_debug;
//...
#endif /*LOG_HPP_*/
</code></pre>
<p>&quot;tis.hpp&quot;</p>
<pre><code class="language-cpp">#ifndef TIS_HPP_
#define TIS_HPP_
...
#include &quot;log.hpp&quot;
...
#endif /*TISIM_HPP_*/
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1164785</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1164785</guid><dc:creator><![CDATA[johsem]]></dc:creator><pubDate>Mon, 30 Oct 2006 18:19:43 GMT</pubDate></item><item><title><![CDATA[Reply to globale instanzen &#x2F; include - Problem on Mon, 30 Oct 2006 18:29:27 GMT]]></title><description><![CDATA[<p>johsem schrieb:</p>
<blockquote>
<p>Sind die &quot;#ifndef&quot; nicht dazu da, das zu verhindern?</p>
</blockquote>
<p>Nein, die schützen dich nur davor, dass eine Headerdatei mehrfach in <em>einer</em> .cpp-Datei eingebunden wird.</p>
<p>In der Headerdatei darf nur eine extern-Deklaration der Variablen stehen. Die Definition muss in genau eine .cpp-Datei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1164795</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1164795</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 30 Oct 2006 18:29:27 GMT</pubDate></item></channel></rss>