Understand the meaning of class first. Class should be understood as a type, like Int,char, as a user-defined type. Use this type to declare a variable, such as int x, MyClass my, and so on. This is like the variable x has an int type, and the variable my has the MyClass type. If you understand this, it's good to explain this, and this is the pointer to my. If there is another variable MyClass mz,mz This is a pointer to MZ. This makes it easy to understand that the type of this should be MyClass *, and that its dereference *this should be a variable of type MyClass. The type variable itself is usually used when the class is defined, because at this time the variable name is not known (it is not possible to fix the actual variable name for general purpose), and the variable itself is used with a pointer like this.
I wrote the blog myself in C + + CPP and HPP, with an example:
. h Code:
#ifndef Circle_h
#define Circle_h
Class Circle
{
Private
Double r;//radius
Public
Circle ();//constructor
Circle (double R);//constructor
Double area ();
};
#endif
. cpp Code;
#include "Circle.h"
Circle::circle ()
{
this->r=5.0;
}
Circle::circle (double R)
{
this->r=r;
}
Double Circle:: Area ()
{
return 3.14*r*r;
}
This allows you to understand this pointer.
Https://www.cnblogs.com/liushui-sky/p/5802981.html
C + + this pointer