<?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[structure]]></title><description><![CDATA[<p>hallo</p>
<p>im header-file (main.hpp) zur main.cpp wird eine structure definiert!<br />
wie kann ich von einer anderen cpp-Datei (Unterprogramm nicht in main.cpp)<br />
auf diese Structure zugreifen?<br />
zur zeit habe ich in beiden cpp-files das header fiel mit include hinzugefügt!<br />
dies ruft eine mehrfach-deklaration hervor.<br />
ich habe auch versucht mit ifndef und define zu arbeiten, kenne aber die<br />
genaue funktionsweise nicht!</p>
<p>lg<br />
patrick</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/98041/structure</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 01:44:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/98041.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 15 Jan 2005 23:39:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to structure on Sat, 15 Jan 2005 23:39:04 GMT]]></title><description><![CDATA[<p>hallo</p>
<p>im header-file (main.hpp) zur main.cpp wird eine structure definiert!<br />
wie kann ich von einer anderen cpp-Datei (Unterprogramm nicht in main.cpp)<br />
auf diese Structure zugreifen?<br />
zur zeit habe ich in beiden cpp-files das header fiel mit include hinzugefügt!<br />
dies ruft eine mehrfach-deklaration hervor.<br />
ich habe auch versucht mit ifndef und define zu arbeiten, kenne aber die<br />
genaue funktionsweise nicht!</p>
<p>lg<br />
patrick</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697670</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697670</guid><dc:creator><![CDATA[MasterDitz]]></dc:creator><pubDate>Sat, 15 Jan 2005 23:39:04 GMT</pubDate></item><item><title><![CDATA[Reply to structure on Sun, 16 Jan 2005 00:35:27 GMT]]></title><description><![CDATA[<p>#include &lt;main.h&gt; hast du drin?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697708</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697708</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Sun, 16 Jan 2005 00:35:27 GMT</pubDate></item><item><title><![CDATA[Reply to structure on Sun, 16 Jan 2005 08:53:31 GMT]]></title><description><![CDATA[<p>ja</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697763</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697763</guid><dc:creator><![CDATA[MasterDitz]]></dc:creator><pubDate>Sun, 16 Jan 2005 08:53:31 GMT</pubDate></item><item><title><![CDATA[Reply to structure on Sun, 16 Jan 2005 09:10:55 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>wegen den Include-Guards :</p>
<pre><code class="language-cpp">// Unit.h
#ifndef UnitH
#define UnitH

// Definitionen

#endif
// Ende der Datei
</code></pre>
<p>das wird aber doch eigentlich automatisch vom BCB angelegt, wenn du Neu/Unit ausführst.</p>
<p>Ich verstehe deinen Aufbau so : Du hast eine Main.cpp und eine Unit.cpp mit jeweiliger Header-Datei. Die Main.h soll die Unit.h includen. Die Unit.h sollte <strong>nicht</strong> die Main.h includen.<br />
Um jetzt die Struktur-Definition in beiden Dateien benutzen zu können, brauchst du bloß noch diese in Unit.h zu verlegen. So ist es logisch und nachvollziehbar.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697766</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697766</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sun, 16 Jan 2005 09:10:55 GMT</pubDate></item><item><title><![CDATA[Reply to structure on Sun, 16 Jan 2005 10:16:51 GMT]]></title><description><![CDATA[<p>Hab nun das 2. header-file in main.hpp includiert.<br />
Und die struct definition zwischen ein #ifndef in die 2. Hpp-Datei gefügt.</p>
<p>Das gibt aber nun eine hübsche mehrfachdeklaration.</p>
<p>Wie hast du das mit dem verlegen gemeint?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697797</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697797</guid><dc:creator><![CDATA[MasterDitz]]></dc:creator><pubDate>Sun, 16 Jan 2005 10:16:51 GMT</pubDate></item><item><title><![CDATA[Reply to structure on Sun, 16 Jan 2005 10:44:20 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>mit verlegen meine ich aus Main ausschneiden und in Unit kopieren</p>
<p>also noch mal ganz genau :</p>
<pre><code class="language-cpp">// Unit Header
#ifndef UnitH
#define UnitH

struct MyFaecher            
{      
    char *Fach;      
};
extern MyFaecher Faecher[5];

//... alle weiteren Definitionen
#endif
// Ende der Datei

// Unit CPP-Datei
#include &quot;Unit.h&quot;
MyFaecher Faecher[5];

// Main Header
#ifndef MainH
#define MainH
#include &quot;Unit.h&quot;
//... alle weiteren Definitionen, aber weder MyFaecher noch Faecher!
#endif
// Ende der Datei

//Main CPP-Datei
...
Faecher[1].Fach = &quot;Hallo&quot;; // Zugriff auf externes Array
</code></pre>
<p>so soll es aussehen. Dann funktioniert es auch!</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697801</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697801</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sun, 16 Jan 2005 10:44:20 GMT</pubDate></item><item><title><![CDATA[Reply to structure on Sun, 16 Jan 2005 10:41:25 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">// Unit CPP-Datei
MyFaecher Faecher[5];
</code></pre>
<p>Das gibt einen daclaration syntax error</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697815</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697815</guid><dc:creator><![CDATA[MasterDitz]]></dc:creator><pubDate>Sun, 16 Jan 2005 10:41:25 GMT</pubDate></item><item><title><![CDATA[Reply to structure on Sun, 16 Jan 2005 10:44:42 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>okay, in Unit.cpp muß natürlich oben noch #include &quot;Unit.h&quot; hinein. Hab ich korrigiert.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697818</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sun, 16 Jan 2005 10:44:42 GMT</pubDate></item><item><title><![CDATA[Reply to structure on Sun, 16 Jan 2005 10:49:00 GMT]]></title><description><![CDATA[<p>Herzlichen Dank auch lieber Kollege, das hat jezt funktioniert!!</p>
<p>Somit ist die morgige Programmabgabe gesichert!!</p>
<p>Noch kurz eine Frage zum Verständnis:<br />
Alle anderen Variablen (int, long) die ich in main.hpp definiert habe, hole ich mir mit extern int in die Unit.cpp.<br />
Warum ist es mit der Struktur nicht gegangen?</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> Gruß und Dank MasterDitz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697826</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697826</guid><dc:creator><![CDATA[MasterDitz]]></dc:creator><pubDate>Sun, 16 Jan 2005 10:49:00 GMT</pubDate></item></channel></rss>