Structure (struct), structure struct

Source: Internet
Author: User

Structure (struct), structure struct

A structure is a data type defined by a programmer and is very similar to a class. Both include data members and function members.

Difference: 1. The class is the reference type, and the structure is the value type.

2. The structure is implicitly sealed, that is, the structure cannot be derived.

The structure type is the same as all value types and contains its own data. Note: The variable of the structure type cannot be null, and the two Structure Variables cannot reference the same object.

Assign a value to the structure

Assigning a structure to another structure means copying values from one structure to another, while the class is copying references.

The structure can have instance constructor and static constructor, but not destructor.

Fields in the structure cannot be initialized.

The structure is sealed and cannot be derived

 

Related Article

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.