(1) Denote the definition of the bit domain within the organization (that is, the variable occupies several bit spaces)
typedef struct _XXX{
unsigned char a:4;
unsigned char c;
} ; XXX
(2) The colon after the constructor plays a split role, which is a method for the class to assign values to member variables. It initializes the list and is more suitable for the constant const type of member variables.
struct _XXX{
_XXX() : y(0xc0) {}
};
(3) The colon after public: and private: means that all members defined later are public or private until the next "public:" or "private:" appears. "private:" is the default processing.
(4) The following is the inheritance of the class name colon.
class derived class name: inheritance method base class name
{
Members of derived classes
};
Inheritance methods: public, private and protected, the default processing is public.
2. Double colon (::) usage
(1) Indicates "domain operator"
Example: Declare a class A. A member function void f() is declared, but the definition of f is not given in the class declaration. Then when defining f outside the class,
It should be written as void A::f(), indicating that this f() function is a member function of class A.
(2) It is used directly before the global function, indicating that it is a global function
Example: In VC, you can add::
(3) Represents referenced member functions and variables, scope member operators
Example: System::Math::Sqrt() is equivalent to ()
The VC is as follows
:: is the "scope decomposition operator" in C++. For example, if a class A is declared, a member function voidf() is declared in class A, but the definition of f is not given in the class declaration. Then when defining f outside the class, it should be written as voidA::f(), indicating that this f() function is a member function of class A.
:: There is also a general usage, which is to use it directly before a global function, indicating that it is a global function. When the member function of a class is the same as a global function outside the class, when the test, when the class is defined in the class, the default call to the member function is the member function of its own. If you want to call a global function with the same name, you must type :: to show the difference. For example, in VC, you can add :: before the API function name when calling the API function.
Copy the codeThe code is as follows:
typedef struct _XXX{
unsigned char a:4;
unsigned char c;
} ; XXX
(2) The colon after the constructor plays a split role, which is a method for the class to assign values to member variables. It initializes the list and is more suitable for the constant const type of member variables.
Copy the codeThe code is as follows:
struct _XXX{
_XXX() : y(0xc0) {}
};
(3) The colon after public: and private: means that all members defined later are public or private until the next "public:" or "private:" appears. "private:" is the default processing.
(4) The following is the inheritance of the class name colon.
Copy the codeThe code is as follows:
class derived class name: inheritance method base class name
{
Members of derived classes
};
Inheritance methods: public, private and protected, the default processing is public.
2. Double colon (::) usage
(1) Indicates "domain operator"
Example: Declare a class A. A member function void f() is declared, but the definition of f is not given in the class declaration. Then when defining f outside the class,
It should be written as void A::f(), indicating that this f() function is a member function of class A.
(2) It is used directly before the global function, indicating that it is a global function
Example: In VC, you can add::
(3) Represents referenced member functions and variables, scope member operators
Example: System::Math::Sqrt() is equivalent to ()
The VC is as follows
:: is the "scope decomposition operator" in C++. For example, if a class A is declared, a member function voidf() is declared in class A, but the definition of f is not given in the class declaration. Then when defining f outside the class, it should be written as voidA::f(), indicating that this f() function is a member function of class A.
:: There is also a general usage, which is to use it directly before a global function, indicating that it is a global function. When the member function of a class is the same as a global function outside the class, when the test, when the class is defined in the class, the default call to the member function is the member function of its own. If you want to call a global function with the same name, you must type :: to show the difference. For example, in VC, you can add :: before the API function name when calling the API function.