The
:: is a
scope resolution operator, it allows the programmer to access items from a Namespace from outside that Namespace. The
std Namespace contains the
cout method, to access that functionality from outside the
std Namespace you have 2 options
cpp
using namespace std;
void main(string[] args)
{
cout<<args[0];
}
Or you can use the scope operator, thus eliminating the need to use the
using statement
cpp
void main(string[] args)
{
std::cout<<args[0];
}
Using the
scope operator is extremely useful in a situation where 2 (or more) Namespaces contains the same identifier, like say you created 2 Namespaces, and they both had an identifier of
Hello, but did different/similar operations. Without the
scope operator you could end up with a redefinition error, meaning that one of the
Hello uses was trying to redefine the other from the other Namespace.
I hope this makes things a little clearer for you
This post has been edited by PsychoCoder: 11 Apr, 2008 - 07:04 PM