First-level pointers and two-level pointers

Source: Internet
Author: User

I don't understand that the root of level two pointers is that I don't know enough about the use of stacks by the program.
It is best to use a first-level pointer to easily modify the value of the pointer object, using a two-level pointer is preferably convenient to modify the pointer value.

#include <iostream>#include <stdio.h>using namespace STD;classhaha{};voidMain () {haha *p (Newhaha);printf("%p\n", p);//The address of the first level pointer    printf("%p\n", &p);//referencing the address of a storage-level pointer    printf("%p\n", *&p);the value stored by the//reference store-level pointer address    cout<<"==================="<< Endl; haha **pp = &p;//Level two pointer stores a pointer address    printf("%p\n", &AMP;PP);//referencing the address that stores a level two pointer    printf("%p\n", *&AMP;PP);//reference store value stored in level two pointer address    printf("%p\n", pp);//Address of level two pointer    printf("%p\n", *PP);The value stored by the address of the//level two pointer    Cin. get ();}

The results of the operation are as follows:

    • &p 0x002dfd60 {0x002ea438 {...}} haha * *
      &p 0x002ea438 {...} haha
      pp 0x002ea438 {...} haha
    • PP 0x002dfd60 {0x002ea438 {...}} haha * *
      &PP 0x002dfd54

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

First-level pointers and two-level 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.