- 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
global scope Symbol: When a global variable has the same name as one of the variables in a local function, you can use:: To distinguish between :
Char Zhou; Global Variables
void Sleep ()
{
Char Zhou; Local Variables
char (local variable) = char (local variable) *char (local variable);
:: char (global variable) =::char (global variable) *char (local variable);
}
- :: Is the scope decomposition operator in C + +. For example, a Class A is declared, a member function VOIDF () is declared in Class A, but no definition of f is given in the declaration of the class, so the definition of F outside the class is written as Voida::f (), which means that the F () function is a member function of Class A. For example
1 classCA2 {3 Public:4 intCa_var;5 intAddintAintb);6 intAddinta); 7 };8 9 //So when you implement this function, you have to write thisTen intCa::add (intAintb) One { A returnA +b; - } - the //In addition, a double colon is often used to represent an element within a class variable as the current class instance, such as: - intCa::add (inta) - { - returnA +:: Ca_var_;//represents the variable Ca_var in the current class instance. +}
C + + double colon:: The role of