The following is a description of the use of colon and double colon in C + +, the need for friends can come to reference the next
(1) denotes the definition of an institution's inner-field (that is, the variable takes up several bit spaces)
Copy Code code as follows:
typedef struct _xxx{
unsigned char a:4;
unsigned char c;
} ; XXX
(2) The colon at the back of the constructor splits, the method that the class assigns to the member variable, initializes the list, and is more applicable to the constant const type of the member variable.
Copy Code code as follows:
struct _xxx{
_xxx (): Y (0xc0) {}
};
(3) Public: and private: The following colon, which means that all the members that are defined later are publicly or privately owned, until the next, or private:, appears. "Private:" for default processing.
(4) After the class name colon is used to define the inheritance of the class.
Copy Code code as follows:
class derived class Name: Inheritance method base class name
{
a member of a derived class
};
Inheritance: Public, private, and protected, and default processing is public.
2. The Double colon (::) Usage
(1) Represents the field operator
Example: Declares a Class A, Class A declares a member function void F (), but does not give the definition of F in the declaration of the class, and when F is defined outside the class, the
is written as a void A::f ( ), which means that the F () function is a member function of Class A.
(2) is used directly before the global function, the representation is a global function
Example: In VC, you can invoke the API function in the call, before the API functions name plus::
(3) refers to reference member functions and variables, scope member operators
Example:: MATH::SQRT () is equivalent to System.Math.Sqrt ()
VC in the following
:: Is the scope decomposition operator in C + +. For example, declaring a Class A, Class A declares a member function VOIDF (), but does not give the definition of F in the declaration of the class, then the definition of f in the class is written as Voida::f (), which means that the F () function is a member function of Class A.
:: There is generally a usage that is used directly before a global function to represent a global function. When a member function of a class has the same name as a global function outside of a class, the test, when the big hint is defined within the class, calls the function name by default as its own member functions; If you want to invoke a global function of the same name, you must hit:: To make a difference. For example, in VC, you can call API functions in the API function name before adding::.