A pointer is an unsigned integer that takes the current system addressing range as the value range. That is to say, the value of the pointer itself represents an address.
Let's take a look at the pointer representation method. For type T, T * is the "to T Pointer" type, that is, a variable of type T * can save a class
The address of the type T object. For example
Char c = 'a ';
Char * p = & c; // p stores the address of c
When we want to access the value pointing to the address through the pointer, we can use the indirect operator *. Taking the above example, to access the value of c, we can
To use * p, do not use only p. In this case, you use the p variable itself. As mentioned above, the variable itself stores
Address. So when you want to output the address of this variable, you can use cout <(int *) p; to output the value of this variable, you can use cout <* p ;.
This method is only used to output basic types. If you want to output other content through pointers, such as strings and user-defined types
The usage is different from the usage here.
Here is a brief introduction of the basic concepts of pointers and some basic operations. There are still a lot of pointer content.
Continue learning with you in the Learning Series!