C + + pointer base usage

Source: Internet
Author: User

#include <iostream>#include<string>using namespacestd;intMain () {Char*a="123"; Char*b="456"; Char*d="789"; Char**c=&A; cout<<static_cast<Const void*> (a) <<endl<<static_cast<Const void*> (*c) <<Endl; //cout<<a<<endl<<c<<endl;*c=b; cout<<static_cast<Const void*> (a) <<endl<<static_cast<Const void*> (*c) <<Endl; //cout<<a<<endl<<c<<endl;a=D; //cout<<a<<endl<<c<<endl;cout<<static_cast<Const void*> (a) <<endl<<static_cast<Const void*> (*c) <<Endl; return 0;}

1 pointers we usually use "sequential use" to pay a pointer value to the address of a function or variable. This use of the two-level pointer is also consistent with the characteristics of the pointer, the pointer value changes and the value of the variable associated with it, but it is necessary to remember that the pointer variable operation is the variable itself, the analysis is not disturbed by ' * '.

2 This small example also demonstrates the "reverse use" of pointers, the associated variable changes, and the pointer changes as well.

This feature is also applicable when referenced in C + +.

C + + pointer base usage

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.