Find the difference between & and * from the Go language

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

* and the difference between &:

  1. & is to take the address symbol, that is, to obtain the address of a variable, such as; &a
  2. * is a pointer operator that can indicate that a variable is a pointer type, or a pointer variable points to a storage unit, that is, the value stored by this address.

Verify from Code:

Build a rect type first:

1. & is the address symbol that takes the address of the Rect type Object

2. * You can indicate that a variable is a pointer type (r is a pointer variable):

3.* can also represent the storage unit that the pointer-type variable points to, that is, the value that this address points to

4. View the address of this pointer variable, the basic data type directly print the address

315 Reads

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.