Difference between pointer and reference (written test required)

Source: Internet
Author: User

1. From a symptom perspective: A pointer can change the value it points to at runtime, and the reference will not change once it is bound to an object.
2. From the memory allocation perspective:ProgramAllocate memory areas for pointer variables, but do not allocate memory areas for references
3. In terms of compilation, the program adds pointers and references to the symbol table during compilation. the symbol table records the variable name and the address corresponding to the variable.The address value corresponding to the pointer variable in the symbol table is the address value of the pointer variable.,The address value corresponding to the referenced symbol table is the address value of the referenced object.. The symbol table will not be changed after it is generated, so the pointer can change the object to which it points (the value in the pointer variable can be changed), but the referenced object cannot be changed.


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.