Pointer Learning Series (1): about pointers

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.