C++ - Problem mit static - Variable

Wolfgang Hinsch <[email protected]>
Newsgroups gmane.linux.suse.programming
Message-ID <[email protected]>
Hallo Liste,

wahrscheinlich stehe ich auf dem Schlauch, denn der Compiler 
hat meistens recht, aber hier verstehe ich ihn nicht:

class nanu
{
    public:
        void nop();
        // Diese Zeile funktioniert
        void noo(){geht_nicht = 7;};

    private:
        static int geht_nicht;
};

main(int argc, char **argv)
{
    nanu nix;
    nix.nop();
}

void nanu::nop()
{
    // Diese beiden Zeilen funktionieren nicht
    geht_nicht = 7;
    nanu::geht_nicht = 7;
}

In der Funktion nop() bringt der Compiler die Meldung
"undefined reference to nanu::geht_nicht". Die 
Inline-Funktion dagegen akzeptiert er.

Weiß jemand warum, oder wo hier was fehlt?

Gruß, Wolfgang

-- 
Um die Liste abzubestellen, schicken Sie eine Mail an:
    [email protected]
Um eine Liste aller verfügbaren Kommandos zu bekommen, schicken
Sie eine Mail an: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.