C + + Learning---pointer correlation

Source: Internet
Author: User
1. Pointer to pointer object

General pointers

int *p1,ival = 42;

P1 = &ival;

Or

int ival =42,*p1=&val;

Represents a pointer object pointing to an address area of the same type, if you want to get the value with a parser *

*P1//P1 stores a memory address, * symbol resolves the address until the value 42

Pointer to pointer object

is a pointer to an int object, and now the object is a pointer object.

int i = 42,*P1,**P2;

P1 = &i;

P2 = &p1;

Need to use * * for a reason

2. Pointers to constants and constant pointers

Point to constant type

const int ival = 42;

const int *P1 = &ival;

Constant pointer

int ival = 42;

int *const P1 = &ival;//p1 will always point to ival

C + + Learning---pointer correlation

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.