Const member of the class, const Member
The const member of the class includes the const data member and the const member function;
1. const data member:
Same as a common const variable, it is initialized during definition and cannot be modified.
2. const member functions:
- The const member function can only access other const member functions, but cannot access non-const member functions.
- Const can modify static data members, which are initialized during definition, but must be declared outside the class.
- Const member functions cannot modify class objects, that is, they cannot modify data members. However, when data members are mutable, they can be modified.
- Const cannot modify the static member function, because const indicates that the class object is not modified, while the static member function belongs to the class and does not involve objects.