Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

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()

like image 414
MistyD Avatar asked Apr 30 '13 22:04

MistyD


Video Answer


1 Answers

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;
}
like image 50
Mike Christensen Avatar answered Sep 18 '22 12:09

Mike Christensen