tags:

views:

124

answers:

1

I saw code like:

using namespace zzzz;

void XX::YY()
{

}

how does :: work if you write like that?

+6  A: 

It's not Java, it's C++. (The using namespace and the :: is the giveaway).

The :: is the "scope operator". It's how in C++ you say that YY is a member of the class XX. Java doesn't need this because methods are always defined within the class they belong to; in C++ you can define them in another file.

quixoto
Or YY is a member of the namespace XX. Hard to tell from here.
Martin York
It isn't that java doesn't need it because methods are defined in the class they belong to, afterall java has scoping in form of packages too. It's just that java uses . for all scoping instead of having different operators for scope access and member access
Grizzly