<?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[Paar Fehler (hat vielleicht was mit static zu tun)]]></title><description><![CDATA[<p>Hallo,</p>
<p>bin grade etwas am verzweifeln. Und zwar bekomm ich folge Fehler:</p>
<blockquote>
<p>stefan@stefan-laptop:~/Downloads/Version 1 P1 fertig$ make<br />
g++ test.o rmmixalTables.o SymbolTable.o RMMIXinstruction.o RMMIXparser.o rmmixHardware.o rmminixos.o Festplatte.o MMU.o Page.o -o test<br />
rmmixHardware.o: In function <code>Festplatte::load(std::basic\_string&lt;char, std::char\_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)': rmmixHardware.cpp:(.text.\_ZN10Festplatte4loadESsi\[Festplatte::load(std::basic\_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)\]+0x2e): undefined reference to</code>Festplatte::Seiten'<br />
rmmixHardware.cpp:(.text._ZN10Festplatte4loadESsi[Festplatte::load(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)]+0x6e): undefined reference to <code>Festplatte::Seiten' rmmixHardware.cpp:(.text.\_ZN10Festplatte4loadESsi\[Festplatte::load(std::basic\_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)\]+0xd7): undefined reference to</code>Festplatte::Seiten'<br />
rmmixHardware.o: In function <code>MMU::isTabelleVorhanden(std::basic\_string&lt;char, std::char\_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)': rmmixHardware.cpp:(.text.\_ZN3MMU18isTabelleVorhandenESs\[MMU::isTabelleVorhanden(std::basic\_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)\]+0x2c): undefined reference to</code>MMU::Tabellenliste'<br />
rmmixHardware.o: In function <code>MMU::einlagern(std::basic\_string&lt;char, std::char\_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)': rmmixHardware.cpp:(.text.\_ZN3MMU9einlagernESsi\[MMU::einlagern(std::basic\_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)\]+0x89): undefined reference to</code>MMU::Tabellenliste'<br />
rmmixHardware.cpp:(.text._ZN3MMU9einlagernESsi[MMU::einlagern(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)]+0xb5): undefined reference to <code>MMU::Tabellenliste' rmmixHardware.cpp:(.text.\_ZN3MMU9einlagernESsi\[MMU::einlagern(std::basic\_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)\]+0x109): undefined reference to</code>MMU::Counter'<br />
rmmixHardware.cpp:(.text._ZN3MMU9einlagernESsi[MMU::einlagern(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)]+0x112): undefined reference to <code>MMU::Counter' rmmixHardware.o: In function</code>MMU::translate(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)':<br />
rmmixHardware.cpp:(.text._ZN3MMU9translateESsi[MMU::translate(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)]+0x60): undefined reference to <code>MMU::Tabellenliste' rmmixHardware.cpp:(.text.\_ZN3MMU9translateESsi\[MMU::translate(std::basic\_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)\]+0xa7): undefined reference to</code>MMU::Tabellenliste'<br />
rmmixHardware.cpp:(.text._ZN3MMU9translateESsi[MMU::translate(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)]+0xd0): undefined reference to <code>MMU::Tabellenliste' Festplatte.o: In function</code>Festplatte::Festplatte()':<br />
Festplatte.cpp:(.text+0x18): undefined reference to <code>Festplatte::Seiten' Festplatte.o: In function</code>Festplatte::Festplatte()':<br />
Festplatte.cpp:(.text+0x3c): undefined reference to <code>Festplatte::Seiten' MMU.o: In function</code>MMU::MMU()':<br />
MMU.cpp:(.text+0x15): undefined reference to <code>MMU::Counter' MMU.cpp:(.text+0x1f): undefined reference to</code>MMU::Zeiger'<br />
MMU.o: In function <code>MMU::MMU()': MMU.cpp:(.text+0x3f): undefined reference to</code>MMU::Counter'<br />
MMU.cpp:(.text+0x49): undefined reference to `MMU::Zeiger'<br />
collect2: ld returned 1 exit status<br />
make: *** [test] Fehler 1</p>
</blockquote>
<p>Die MMU.h (in der cpp hab ich kaum was drin)</p>
<pre><code class="language-cpp">#ifndef MMU_H
#define	MMU_H

#include &lt;string&gt;
#include &quot;Festplatte.h&quot;

using namespace std;

#define INDEX 1
#define TRANSLATED 2

class MMU {
public:
    static const int maxProzesse = 20; // Anzahl von Seitentabellen (eine je Prozess)
    static const int maxPage = 8; // Virtueller Adressraum in 512 Worten
    static const int HardwareSize = 4; // Physikalischer Adressraum in 512 Worten
    static const int PageSize = 512;

    struct Tabelle {
        string Prozess;
        int Seitentabelle [maxPage][2];
    };
public:
    static Tabelle Tabellenliste[maxProzesse];
    static int Zeiger;
    static int Counter;

    static bool isTabelleVorhanden(string job) {
        for (int i = 0; i &lt; maxProzesse; i++) {
            if (Tabellenliste[i].Prozess == job) return true;
        }
        return false;
    }

    static void einlagern(string job, int Seite) {
        if (!MMU::isTabelleVorhanden(job)) {
            for (int i = 0; i &lt; maxProzesse; i++) {
                if (Tabellenliste[i].Prozess == &quot;&quot;) {
                    Tabellenliste[i].Prozess = job;
                }
            }
        }

        if (Counter &gt;= HardwareSize) { // es gibt kein Platz, andere Seite entfernen

        }

        // neue Seite einfügen
        Festplatte::load(job, Seite);

        Counter++;

    }
public:

    MMU();
    MMU(const MMU&amp; orig);
    virtual ~MMU();

    static int translate(string job, int virtuelle) {
        int Seite = virtuelle / PageSize;
        int Offset = virtuelle % PageSize;

        for (int i = 0; i &lt; maxProzesse; i++) {
            if (MMU::Tabellenliste[i].Prozess == job) { // finde Seitentabelle zum Prozess
                for (int t = 0; t &lt; maxPage; t++) {
                    if (MMU::Tabellenliste[i].Seitentabelle[t][INDEX] == Seite) { // Seite eingelagert?
                        return (MMU::Tabellenliste[i].Seitentabelle[t][TRANSLATED] * PageSize + Offset);
                    }
                }
                // Seite muss eingelagert werden
                MMU::einlagern(job, Seite);
                return translate(job, virtuelle);
            }
        }
        // Seite muss eingelagert werden
        MMU::einlagern(job, Seite);
        return translate(job, virtuelle);
    }
};

#endif	/* MMU_H */
</code></pre>
<p>und teil rmmixHardware.cpp:</p>
<pre><code class="language-cpp">case RMMIXAL::LDWI: cout &lt;&lt; instruction.fields[2] &lt;&lt; &quot;#1&quot;;

            registers[ instruction.fields[1] ] = dataMemory[MMU::translate(instruction.JobName, instruction.fields[2])];

            break;
        case RMMIXAL::LDW: cout &lt;&lt; registers[ instruction.fields[2] ] &lt;&lt; &quot;#2&quot;;
            registers[ instruction.fields[1] ] = dataMemory[ registers[MMU::translate(instruction.JobName, instruction.fields[2])] ];

            break;
        case RMMIXAL::STWI: cout &lt;&lt; instruction.fields[2] &lt;&lt; &quot;#3&quot;;
            dataMemory[MMU::translate(instruction.JobName, instruction.fields[2])] = registers[ instruction.fields[1] ];

            break;
        case RMMIXAL::STW: cout &lt;&lt; instruction.fields[2] &lt;&lt; &quot;#4&quot;;
            dataMemory[ registers[MMU::translate(instruction.JobName, instruction.fields[2]) ] ] = registers[ instruction.fields[1] ];

            break;
</code></pre>
<p>naja verwende zum ersten mal static in c++. Da ich eh nur eine Festplatte und MMU habe brauch ich so nicht die ganze Zeit die Variablen mitübergeben.</p>
<p>Hab das komplette Projekt mal hochgeladen:<br />
<a href="http://www.file-upload.net/download-3088858/Version-1-P1-fertig.tar.gz.html" rel="nofollow">http://www.file-upload.net/download-3088858/Version-1-P1-fertig.tar.gz.html</a><br />
(läuft evtl. nur unter Linux)</p>
<p>Gruß<br />
Geddon</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/279591/paar-fehler-hat-vielleicht-was-mit-static-zu-tun</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 12:16:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/279591.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 30 Dec 2010 02:50:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Paar Fehler (hat vielleicht was mit static zu tun) on Thu, 30 Dec 2010 02:50:59 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>bin grade etwas am verzweifeln. Und zwar bekomm ich folge Fehler:</p>
<blockquote>
<p>stefan@stefan-laptop:~/Downloads/Version 1 P1 fertig$ make<br />
g++ test.o rmmixalTables.o SymbolTable.o RMMIXinstruction.o RMMIXparser.o rmmixHardware.o rmminixos.o Festplatte.o MMU.o Page.o -o test<br />
rmmixHardware.o: In function <code>Festplatte::load(std::basic\_string&lt;char, std::char\_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)': rmmixHardware.cpp:(.text.\_ZN10Festplatte4loadESsi\[Festplatte::load(std::basic\_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)\]+0x2e): undefined reference to</code>Festplatte::Seiten'<br />
rmmixHardware.cpp:(.text._ZN10Festplatte4loadESsi[Festplatte::load(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)]+0x6e): undefined reference to <code>Festplatte::Seiten' rmmixHardware.cpp:(.text.\_ZN10Festplatte4loadESsi\[Festplatte::load(std::basic\_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)\]+0xd7): undefined reference to</code>Festplatte::Seiten'<br />
rmmixHardware.o: In function <code>MMU::isTabelleVorhanden(std::basic\_string&lt;char, std::char\_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)': rmmixHardware.cpp:(.text.\_ZN3MMU18isTabelleVorhandenESs\[MMU::isTabelleVorhanden(std::basic\_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)\]+0x2c): undefined reference to</code>MMU::Tabellenliste'<br />
rmmixHardware.o: In function <code>MMU::einlagern(std::basic\_string&lt;char, std::char\_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)': rmmixHardware.cpp:(.text.\_ZN3MMU9einlagernESsi\[MMU::einlagern(std::basic\_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)\]+0x89): undefined reference to</code>MMU::Tabellenliste'<br />
rmmixHardware.cpp:(.text._ZN3MMU9einlagernESsi[MMU::einlagern(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)]+0xb5): undefined reference to <code>MMU::Tabellenliste' rmmixHardware.cpp:(.text.\_ZN3MMU9einlagernESsi\[MMU::einlagern(std::basic\_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)\]+0x109): undefined reference to</code>MMU::Counter'<br />
rmmixHardware.cpp:(.text._ZN3MMU9einlagernESsi[MMU::einlagern(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)]+0x112): undefined reference to <code>MMU::Counter' rmmixHardware.o: In function</code>MMU::translate(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)':<br />
rmmixHardware.cpp:(.text._ZN3MMU9translateESsi[MMU::translate(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)]+0x60): undefined reference to <code>MMU::Tabellenliste' rmmixHardware.cpp:(.text.\_ZN3MMU9translateESsi\[MMU::translate(std::basic\_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)\]+0xa7): undefined reference to</code>MMU::Tabellenliste'<br />
rmmixHardware.cpp:(.text._ZN3MMU9translateESsi[MMU::translate(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)]+0xd0): undefined reference to <code>MMU::Tabellenliste' Festplatte.o: In function</code>Festplatte::Festplatte()':<br />
Festplatte.cpp:(.text+0x18): undefined reference to <code>Festplatte::Seiten' Festplatte.o: In function</code>Festplatte::Festplatte()':<br />
Festplatte.cpp:(.text+0x3c): undefined reference to <code>Festplatte::Seiten' MMU.o: In function</code>MMU::MMU()':<br />
MMU.cpp:(.text+0x15): undefined reference to <code>MMU::Counter' MMU.cpp:(.text+0x1f): undefined reference to</code>MMU::Zeiger'<br />
MMU.o: In function <code>MMU::MMU()': MMU.cpp:(.text+0x3f): undefined reference to</code>MMU::Counter'<br />
MMU.cpp:(.text+0x49): undefined reference to `MMU::Zeiger'<br />
collect2: ld returned 1 exit status<br />
make: *** [test] Fehler 1</p>
</blockquote>
<p>Die MMU.h (in der cpp hab ich kaum was drin)</p>
<pre><code class="language-cpp">#ifndef MMU_H
#define	MMU_H

#include &lt;string&gt;
#include &quot;Festplatte.h&quot;

using namespace std;

#define INDEX 1
#define TRANSLATED 2

class MMU {
public:
    static const int maxProzesse = 20; // Anzahl von Seitentabellen (eine je Prozess)
    static const int maxPage = 8; // Virtueller Adressraum in 512 Worten
    static const int HardwareSize = 4; // Physikalischer Adressraum in 512 Worten
    static const int PageSize = 512;

    struct Tabelle {
        string Prozess;
        int Seitentabelle [maxPage][2];
    };
public:
    static Tabelle Tabellenliste[maxProzesse];
    static int Zeiger;
    static int Counter;

    static bool isTabelleVorhanden(string job) {
        for (int i = 0; i &lt; maxProzesse; i++) {
            if (Tabellenliste[i].Prozess == job) return true;
        }
        return false;
    }

    static void einlagern(string job, int Seite) {
        if (!MMU::isTabelleVorhanden(job)) {
            for (int i = 0; i &lt; maxProzesse; i++) {
                if (Tabellenliste[i].Prozess == &quot;&quot;) {
                    Tabellenliste[i].Prozess = job;
                }
            }
        }

        if (Counter &gt;= HardwareSize) { // es gibt kein Platz, andere Seite entfernen

        }

        // neue Seite einfügen
        Festplatte::load(job, Seite);

        Counter++;

    }
public:

    MMU();
    MMU(const MMU&amp; orig);
    virtual ~MMU();

    static int translate(string job, int virtuelle) {
        int Seite = virtuelle / PageSize;
        int Offset = virtuelle % PageSize;

        for (int i = 0; i &lt; maxProzesse; i++) {
            if (MMU::Tabellenliste[i].Prozess == job) { // finde Seitentabelle zum Prozess
                for (int t = 0; t &lt; maxPage; t++) {
                    if (MMU::Tabellenliste[i].Seitentabelle[t][INDEX] == Seite) { // Seite eingelagert?
                        return (MMU::Tabellenliste[i].Seitentabelle[t][TRANSLATED] * PageSize + Offset);
                    }
                }
                // Seite muss eingelagert werden
                MMU::einlagern(job, Seite);
                return translate(job, virtuelle);
            }
        }
        // Seite muss eingelagert werden
        MMU::einlagern(job, Seite);
        return translate(job, virtuelle);
    }
};

#endif	/* MMU_H */
</code></pre>
<p>und teil rmmixHardware.cpp:</p>
<pre><code class="language-cpp">case RMMIXAL::LDWI: cout &lt;&lt; instruction.fields[2] &lt;&lt; &quot;#1&quot;;

            registers[ instruction.fields[1] ] = dataMemory[MMU::translate(instruction.JobName, instruction.fields[2])];

            break;
        case RMMIXAL::LDW: cout &lt;&lt; registers[ instruction.fields[2] ] &lt;&lt; &quot;#2&quot;;
            registers[ instruction.fields[1] ] = dataMemory[ registers[MMU::translate(instruction.JobName, instruction.fields[2])] ];

            break;
        case RMMIXAL::STWI: cout &lt;&lt; instruction.fields[2] &lt;&lt; &quot;#3&quot;;
            dataMemory[MMU::translate(instruction.JobName, instruction.fields[2])] = registers[ instruction.fields[1] ];

            break;
        case RMMIXAL::STW: cout &lt;&lt; instruction.fields[2] &lt;&lt; &quot;#4&quot;;
            dataMemory[ registers[MMU::translate(instruction.JobName, instruction.fields[2]) ] ] = registers[ instruction.fields[1] ];

            break;
</code></pre>
<p>naja verwende zum ersten mal static in c++. Da ich eh nur eine Festplatte und MMU habe brauch ich so nicht die ganze Zeit die Variablen mitübergeben.</p>
<p>Hab das komplette Projekt mal hochgeladen:<br />
<a href="http://www.file-upload.net/download-3088858/Version-1-P1-fertig.tar.gz.html" rel="nofollow">http://www.file-upload.net/download-3088858/Version-1-P1-fertig.tar.gz.html</a><br />
(läuft evtl. nur unter Linux)</p>
<p>Gruß<br />
Geddon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2000228</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2000228</guid><dc:creator><![CDATA[Geddon]]></dc:creator><pubDate>Thu, 30 Dec 2010 02:50:59 GMT</pubDate></item><item><title><![CDATA[Reply to Paar Fehler (hat vielleicht was mit static zu tun) on Thu, 30 Dec 2010 08:19:23 GMT]]></title><description><![CDATA[<p>Hast Du daran gedacht, daß Du für statische Membervariablen Speicherplatz (außerhalb der Klassendefinition) zur Verfügung stellen mußt?</p>
<pre><code class="language-cpp">class Beispiel
{
   static int i;
}
int Beispiel::i;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2000244</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2000244</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Thu, 30 Dec 2010 08:19:23 GMT</pubDate></item><item><title><![CDATA[Reply to Paar Fehler (hat vielleicht was mit static zu tun) on Thu, 30 Dec 2010 19:21:19 GMT]]></title><description><![CDATA[<p>Belli hat recht.</p>
<pre><code class="language-cpp">class foo
{
  static int bar; // &lt;-- DeKLARAtion
};

int foo::bar;     // &lt;-- DeFINItion
</code></pre>
<p>Bei Dir fehlen die Definitionen der statischen Datenelemente.</p>
<p>Dass Du überhaupt eine Klasse mit statischen Datenelementen als Abstraktion wählst, finde ich seltsam. Warum nicht einfach nur freie Funktionen?</p>
<p>Header:</p>
<pre><code class="language-cpp">#ifndef FESTPLATTE_HPP_INCLUDED
#define FESTPLATTE_HPP_INCLUDED

int dies();

void das(int);

#endif // FESTPLATTE_HPP_INCLUDED
</code></pre>
<p>cpp-Datei:</p>
<pre><code class="language-cpp">#include &quot;festplatte.hpp&quot;

namespace {

int fp_zustand = 0;

} // anonymer Namensraum

int dies()
{
  return fp_zustand;
}

void das(int x)
{
  fp_zustand = x;
}
</code></pre>
<p>Beachte: Es tauchen keine Deklarationen von Objekten mit statischer Lebensdauer im Header auf.</p>
<p>edit: copy&amp;paste fehler entfernt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2000256</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2000256</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Thu, 30 Dec 2010 19:21:19 GMT</pubDate></item><item><title><![CDATA[Reply to Paar Fehler (hat vielleicht was mit static zu tun) on Thu, 30 Dec 2010 18:50:00 GMT]]></title><description><![CDATA[<p>krümelkacker schrieb:</p>
<blockquote>
<p>Dass Du überhaupt eine Klasse mit statischen Datenelementen als Abstraktion wählst, finde ich seltsam. Warum nicht einfach nur freie Funktionen?</p>
</blockquote>
<p>Lass mich raten... du nutzt auch keine namespaces?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2000475</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2000475</guid><dc:creator><![CDATA[wxSkip]]></dc:creator><pubDate>Thu, 30 Dec 2010 18:50:00 GMT</pubDate></item><item><title><![CDATA[Reply to Paar Fehler (hat vielleicht was mit static zu tun) on Thu, 30 Dec 2010 19:41:07 GMT]]></title><description><![CDATA[<p>wxSkip schrieb:</p>
<blockquote>
<p>Lass mich raten... du nutzt auch keine namespaces?</p>
</blockquote>
<p>Ich nutze sowohl sowohl Klassen als auch Namensräume. Beispielsweise habe ich in dem obigen Beispiel einen anonymen Namensraum verwendet. Ich sehe nur keinen Sinn darin, in diesem Fall eine Klasse mit ausschließlich statischen Elementen zu definieren. Es bringt doch nichts. Im Gegenteil: Man muss so im Header auch verraten, was für Variablen für die Verwaltung des Zustands benötigt werden.</p>
<p>btw: Ich find's schade, dass Dein kompletter &quot;Beitrag&quot; sich auf diese eine Zeile beschränkt hat, die ich zitiert habe. Hättest ja auch mal erläutern können, warum eine Klasse hier angeblich sinvoll eingesetzt werden könne.</p>
<p>Eben beim Überfliegen des Originalposts habe ich noch ein &quot;using namespace std;&quot; in einer Header-Datei entdeckt. Das gehört sich natürlich nicht und muss auch mal erwähnt werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2000499</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2000499</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Thu, 30 Dec 2010 19:41:07 GMT</pubDate></item><item><title><![CDATA[Reply to Paar Fehler (hat vielleicht was mit static zu tun) on Thu, 30 Dec 2010 19:51:23 GMT]]></title><description><![CDATA[<p>Okay, der war ein bisschen knapp. Warum verwendest du anonyme Namespaces? Den Sinn kenne ich nicht.</p>
<p>Der Sinn davon, eine Klasse mit statischen Membern statt eines namespace zu verwenden, ist IMHO, dass du globale Variablen private machen kannst. Der Nachteil ist natürlich, dass du keine using-Deklarationen verwenden kannst.<br />
Wobei sich das mit den Variablen natürlich relativiert, wenn du sie in der Implementationsdatei deklarierst (du hättest bloß noch Probleme bei Mehrfachdeklaration in einer anderen C++-Datei).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2000506</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2000506</guid><dc:creator><![CDATA[wxSkip]]></dc:creator><pubDate>Thu, 30 Dec 2010 19:51:23 GMT</pubDate></item><item><title><![CDATA[Reply to Paar Fehler (hat vielleicht was mit static zu tun) on Thu, 30 Dec 2010 20:11:42 GMT]]></title><description><![CDATA[<p>wxSkip schrieb:</p>
<blockquote>
<p>Warum verwendest du anonyme Namespaces? Den Sinn kenne ich nicht.</p>
</blockquote>
<p>Damit man die enthaltenen Objekte von einer anderen Übersetzungseinheit aus nicht direkt ändern kann und um Namenskollisionen aus dem Weg zu gehen, habe ich sie eingesetzt. Quasi &quot;private&quot; auf Ebene der Übersetzungseinheiten. Sonst könntest Du in einer anderen ÜE einfach schreiben</p>
<pre><code class="language-cpp">extern int fp_zustand;
</code></pre>
<p>und darüber den Wert von fp_zustand manipulieren. Alternativ kannst Du natürlich fp_zustand mit interner Bindung deklarieren. Das wäre aber nicht im Sinne des C++-Erfinders.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2000510</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2000510</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Thu, 30 Dec 2010 20:11:42 GMT</pubDate></item></channel></rss>