The basic idea of a class is data abstraction and encapsulation
1.this
The member function accesses the object that called it through an additional implicit parameter called this, which is initialized with the object requesting the function when we call a function.
If the name of a class is Sale, an object is total and the member function is ISBN
TOTAL.ISBN () can be understood as SALE::ISBN (total);
Any custom named this behavior is illegal.
Because this is always pointing to the "this" object, this is a constant pointer and we are not allowed to change the address this is pointing to.
2.
Introducing the const member function
We define such a function within the class.
int ISBN () const{return This->book;}
One important function of the Const keyword for a function is to modify the type of the implicit pointer t,his pointer.
By default, the this pointer is a constant pointer to a very version of the class type. This means that this is a constant pointer, and the address pointed to cannot be changed, but the contents of the directed class can be changed.
By default We cannot bind this to a constant object, that is, we cannot call a normal member function on a constant object.
So if we want a const type object to call a
HLW's C + + learning notes and the like