What is the difference between A and s::A ?
The biggest difference is that the declaration of A also a definition, while the definition of s::A is not. I'm not sure what you mean by "special rules", but static has a different meaning in each case.
In the namespace area, it gives an internal connection so that the object is not visible outside the current translation unit. Note that static is redundant here, because by default, constant variables in the namespace have internal bindings.
In the realm of a class, this means that there is a separate object independent of any instance of the class.
when will their use be replaced by their literal meaning?
Since both are integral constants with an initializer in the declaration, both can be used in constant expressions, and the compiler can replace their values ββwith compile-time constants.
Perhaps a more appropriate question is: when is a definition needed?
In C ++ 11, it is required if the variable is used by odr - roughly speaking, if you are doing something that requires the address of a variable, not its value.
In C ++ 03, I think it was necessary if the variable is used at all, although no diagnostics are required, and many compilers will not complain if you use only its value. I could be wrong; the old rules were pretty confusing, and I'm happy that I could forget them now.
when can i get his address?
This requires that the variable has a definition in both C ++ 03 and C ++ 11. In the definition, memory is allocated for the variable, so it has an address.
When do I need to identify them separately?
Declaring a variable in a namespace scope is also a definition unless you declare it extern ; therefore, your first variable does not need a separate definition.
Declaring a variable in a class is not a definition; therefore, your second variable needs a separate definition in C ++ 03, and in C ++ 11 if it is used by odr.