Single and Double colons in C ++
1. colon (:) usage
(1) represents the definition of the intra-organization bit domain (that is, the variable occupies several bit spaces)
Typedef struct _ XXX {
Unsigned char A: 4;
Unsigned char C;
}; XXX
(2) The colon following the constructor acts as a segmentation function. It is a class-based method for assigning values to member variables. The initialization list is more suitable for the constant const type of member variables.
Struct _ XXX {
_ XXX (): Y (0xc0 ){}
};
(3) The colons after public: and private: indicate that all the Members defined later are public or private until the next "public:" or "Private:" appears. "Private:" is the default processing.
(4) the class name is followed by the colon to define the inheritance of the class.
Class derived class name: Inheritance Method Base Class Name
{
Member of the derived class
};
Inheritance Method: public, private, and protected. The default process is public.
2. Double colon (: :) usage
(1) "domain operator"
For example, a Class A is declared, and Class A declares a member function void F (), but the definition of F is not given in the class declaration, when F is defined outside the class,
Void A: F () indicates that the F () function is a member function of Class.
(2) It is used directly before the global function to indicate that it is a global function.
For example, in VC, you can add ::
(3) Reference member functions and variables, and scope member operators
For example, system: Math: SQRT () is equivalent to system. Math. SQRT ()