C + + pointers

Source: Internet
Author: User

Directory:

1, simple use of pointers

2. Complex pointer usage

3. Some special pointer types

4. Summary


First, simple use of pointers

#include  <iostream>using namespace std;int main () {         //null 0x0 is actually the same,  are empty pointers         int * ip1, *ip2=null;        cout << ip2 <<  endl;        //define pointers, in fact, the following is useless          double dp, *dp2;        int ival =  42;        int *p = &ival;         // p points to ival address value         cout  << p << endl;        ip1 = p;         //  as with the P variable, the pointer to the address value is assigned to the ip1         cout << ip1 << endl;        cout <<  *p << endl;        cout << ival  << endl;        cout << *ip1  << endl;}


From the above example, you should understand that the pointer is probably a kind of reference data type, and Java almost, Java is all object, reference to objects. The purpose is to implement an indirect access to other types, objects, and attributes.


II. Complex pointer usage

1. accessing struct fields by pointer

2.

Iii. Some special types of pointers

Iv. Summary



-------------Smoke a cigarette and go to sleep. I have to go to work tomorrow-----write it tomorrow-------

C + + pointers

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.