1.
Scope symbol:: The front of the general is the class name, followed by the class is generally the member name, C + + as an example to avoid different classes have the same name of the member and the scope of the way to differentiate
For example: A, B represents two classes, and a member is member in a A, B. So
A::member represents a member of Class A member
B::member represents a member in Class B member
2.
Global scope Symbol:
For example:
#include <stdio.h>int count = 0; Global variable 0void main () { int count = 10;//local variable of printf ("Count =%d\n", count);//local variable masks global variable so the output is ten { int Count =; printf ("Count =%d\n",:: Count); Scope symbol indicates reference global variable 0 //::sort}}
As a global scope symbol, double colons are placed at the beginning. This is similar to the file path under Linux, where "/" is placed at the beginning to represent an absolute path, and is placed in the middle to represent a subdirectory.
:: A symbol can specify either a class or a variable and a namespace:
If a function is placed globally, the global function is the global namespace if the variable is defined globally, if a namespace is placed globally.
3.
另外,双冒号也常常用于在类变量内部作为当前类实例的元素进行表示:
Class CA {public: int ca_var; int add (int a, int b); int add (int a);}; scope int Ca::add (int a, int b) { return a + B;}//In addition, a double colon is represented inside a class variable as an element of the current class instance int ca::add (int a) { return a +:: Ca_var ;} Represents a variable in the current class instance Ca_var
Double colon action in C + +