"Manuel" <> wrote in message
news:43afb6e7$0$1065$. ..
> Hi!
> Anyone can explain me why this work:
>
> --------------------------
> class Rect
> {
> public:
> Rect()
> {num ++;}
>
> ~Rect()
> {num --;}
>
> static void pippo(){num ++;};
>
> protected:
> static int num;
>
> };
> int num = 0;
>
> main(){}
> -------------------------
>
> and this not work?
>
> -------------------------
> class Rect
> {
> public:
> Rect()
> {num ++;}
>
> ~Rect()
> {num --;}
>
> static void pippo();
>
> protected:
> static int num;
>
> };
> int num = 0;
> void Rect:
ippo() {num ++;}
> main(){}
>
> ---------------------------
>
> Thanks!
Actually, it's fairly simple. Rect:

ippo() is static. Which means it's
only supposed to be used on static variables. They have no this pointer.
Neighter of those should work.
change num to static and it should work.
static int num;
then outside the class
int Rect::num = 0;
I can not tell you why your first version compiled. It shouldn't of as far
as I'm aware.