On Saturday, 2 May 2015 23:59:13 UTC+3, Victor Bazarov wrote:
> On 5/2/2015 3:56 PM, Ian Collins wrote:
> > Stefan Ram wrote:
> >> How to call the »::« in
> >>
> >> ::std::cout
> >
> > The superfluous scope resolution operator?
:)
> In this case, probably. In general, it's not superfluous if it helps
> the compiler to distinguish a global symbol from a local one:
>
> int i = 42;
> int main() {
> double i = .14159;
> ::i = 666;
> }
Actually the front :: is good for indicating that a generally useful
name (like 'rename', 'open', 'CreateFile' etc.) is meant as a global
name not local name. It is fine for clarity even when there are no such
name in local scope because it may make sense to use same name locally.
A programmer who creates and hides cryptic names like 'i' or even
some well-known library cryptic global names (like 'std', 'freopen' or
'snprintf') in more local scope deserves beating up and out.
It is anyway complication, confusion and headache to read the code
that practices such name-hiding so it should be rewritten not guarded
against.