MistyD
MistyD

Reputation: 17223

what does ::SomeMethod() Mean - scope resolution operator

I know that :: is the scope resolution operator. However what does it mean if something simply starts with a scope resolution operator. I know that something needs to be placed before the scope resolution operator (either a class name or a namespace). What if there is nothing before a scope resolution operator. For instance ::Method()

Upvotes: 5

Views: 291

Answers (1)

Mike Christensen
Mike Christensen

Reputation: 91608

It refers to the global scope. For example:

int count = 0;

int main(void) {
  int count = 0;
  ::count = 1;  // set global count to 1
  count = 2;    // set local count to 2
  return 0;
}

Upvotes: 10

Related Questions