Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 12
    static is probably the most-overloaded keyword in C++. Your code's meaning varies widely depending on whether it is at namespace scope, at class scope, or at function scope. You might want to clarify that. Commented Sep 14, 2010 at 13:25
  • 4
    @sbi: I thought I did already. Function scope (where it is a storage class specifier) and file scope (where it is a linkage specifier). Class members and namespace scoped variables specifically are not of concern to me in respect to this question, although if anyone feels there is an interesting distinction, feel free to cover that too. Commented Sep 14, 2010 at 16:09
  • @Clifford: I'm sorry I overlooked those last words. However, this revealed a misunderstanding on your part: In C++, file scope is namespace scope. If you declare anything out side of any namespace, it will simply belong to the global namespace (and is accessible through a prefixed :: with no identifier in front). I'm not aware of any meaningful differences between the global namespace and any namespace nested in it. There certainly isn't any regarding static objects. Commented Sep 14, 2010 at 18:04
  • 1
    linkage is different from visibility, by using them interchangeably you're going to confuse the people you talk to and probably also yourself. Commented Sep 15, 2010 at 0:48
  • 2
    @Ben, @sbi: I did not intend to suggest that file scope and static linkage were the same, merely that static linkage implies file scope. In this sense scope (or visibility) is an attribute of static and external linkage, not a synonym for either. I feel that the original question remains clear and well formed, and that we are merely discussing the comments made in response to sbi's somewhat condescending remark. We are discussing imprecise semantics of English here rather than my understanding, so I think we can stop. Commented Sep 15, 2010 at 11:10