unknown operator

hello everyone,
can you tell me what does :: do?
It's the scope operator. It's tells the compiler which class/namespace to look in for a certain identifier.

example with a namespace

1
2
3
4
5
6
7
8
9
10
namespace nms
{
  int var;
}

int main()
{
  var = 5;  // ERROR, there is no 'var' in this namespace
  nms::var = 5;  // OK, compiler looks in the 'nms' namespace and finds var
}


example with a class:

1
2
3
4
5
6
7
8
9
10
11
12
class Cls
{
  void Function(); // function prototype
}

void Function()  // this defines a GLOBAL function
{
}

void Cls::Function()  // this defines the 'Function' within the Cls class
{
}
i got it. thanks = ))
Topic archived. No new replies allowed.