Whit is the difference between 1 and 2?
1:
namespace Foo {
int bar;
}
2:
class Foo {
public:
static int bar;
}
If bar
is a function, then the difference is that static class member
can access class private
members.
But sometimes we just need to store a constant
for example. Then we have a choice.
Is there any difference between these two?
And what would be the reason to choose one over another.
I have searched this, and I am surprised there's no answer already on the web.