Re: C++ - Problem mit static - Variable

Tobias Erbsland <[email protected]>
Newsgroups gmane.linux.suse.programming
Organization PrintSoft (Schweiz) AG
Message-ID <[email protected]>
Hallo

> 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;
> };

Jede statische variable musst du nicht nur deklarieren, sondern auch 
implementieren:

In deinem Beispiel fehlt:

nanu::geht_nicht = 0;

Als implementation der statischen variable.

Gruss
Tobias


-- 
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.