It might be helpful if some of the more experienced members chime in1
. I've done some Google searches, and there seem to be some areas where the "side effects" (ex. lack of consistency) of globals are beneficial (and the users here seem to have quite diverse backgrounds and are possibly able to provide their own examples).
A user named "Jamie" explains his/ her use of global random number generators in the comment section of the following link, and the post before that mentions threads (of which I have close to no understanding):
|Synonym for well-known: notorious.|
I have admittedly never read any of his books, but they (his books) seem to be quite popular among the beginner/ intermediate ranks. That being said, I can't be quick to judge him, as, wherever possible, I prefer to judge by my own knowledge and not by the words of others.
I do concede that there may be instances where shared data is better as a global variables.
That is, however, as far as I think I will take my end of this discussion. As I said in my first post, this question has been asked (and answered) many times. With that, I leave more links:
You can find many of their answers to this question in some of the links provided. If you do some extra searching, you're likely to find more.
With regards to members of a namespace, according to the working draft of the C++ standard:
ISO N3960 § 3.3.2.
|Every name is introduced in some portion of program text called a declarative region, which is the largest part|
of the program in which that name is valid, that is, in which that name may be used as an unqualified name
to refer to the same entity. In general, each particular name is valid only within some possibly discontiguous
portion of program text called its scope. To determine the scope of a declaration, it is sometimes convenient
to refer to the potential scope of a declaration. The scope of a declaration is the same as its potential scope
unless the potential scope contains another declaration of the same name. In that case, the potential scope
of the declaration in the inner (contained) declarative region is excluded from the scope of the declaration
in the outer (containing) declarative region.
So I guess components of the standard namespace are indeed global. That means I... I... I was wrong. :(