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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With