::被称为作用域解析符,用于引入一个作用域。
::bind表示使用的是全局名空间内的bind函数。
在c++里引入了名空间(namespace)的概念,比如std::cout就表示std名空间内的cout对象。
c++里的范围有以下几种,全局作用域,名空间作用域,类作用域。编译器在编译时,默认从同级别的范围内开始解析符号,采用由内而外的顺序进行解析函数名。
假定有如下函数
- void DoSomething()
- {
- }
- namespace SomeSpace
- {
- void DoSomething();
- class SomeClass
- {
- public:
- void DoSomething();
- void DoAnother()
- {
- DoSomething(); //直接调用最近的,也就是该类里面定义的DoSomething
- SomeSpace::DoSomething(); //调用SomeSpace名空间内的DoSomething
- ::DoSomething(); //调用全局范围内的DoSomething函数。
- }
- };
- }
当写一个类时,有可能在该类范围内定义了一个与全局函数同名同参数的函数,这时,全局范围内的,默认情况下就被隐藏起来了,除非显式指定范围,使用"::"符号。
from http://hi.baidu.com/tim_bi/blog/item/e68833f3c9b3f25c352accad.html