Now i want to know what was the problem with your code...
It dont make any sense. It is a syntax error, so it cant be something with the placement in a class or someting, but on the other hand, exactly the same syntax does work in a simple program...
Some questions:
-Wy cant you declare a variable inside a class?
-Wy gave the compiler a syntax "{" error, if the problem was with the location?
-How does a static declaration works?
1. You can. Declaration and initialization are two different things. int x;declares a variable named x of type int. x = 5;initializes or assigns x the value 5. int x = 5; both declares and initializes x. Your code was declaring and initializing.
2. That has to do with the way parsing works. The compiler doesn't know what you were trying to do. That is, it does not know the semantics of your code. But the compiler does know the syntax of C++, and '{' is not allowed there.
3. static has multiple meanings. Inside a class, as in my example above, it means that there is only one x, no matter how many instances of Foo there are. It also means that you don't have to declare an object of type Foo in order for the variable Foo::x to exist.