3

So for a while I've been using...

using namespace::std;

and recently I realized that's supposed to be

using namespace std;

Can somebody explain to me why what I was doing worked, and how it differs from the correct way of declaring the usage of a certain namespace?

kikiotsuka
  • 79
  • 8

1 Answers1

6

The first version works because the compiler sees it as

using namespace ::std;
// Notice space^

That is simply telling the compiler to look for the name-space std in the global scope.

The scope operator :: without anything on the left-hand side is the same as the global scope.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621