Structure and class

Source: Internet
Author: User
Structure and class

Structure: aggregate, which is a derived data type

Array/structure/enumeration/Union:
Similarities:
All-aggregates
Not required:
1. the array contains elements of the same data type. Each element has a number mark under the array.
2. Variables of different data types can be included.
3. The Enum keyword is used to declare enumeration. It is generally used to declare a regular Object Body of an element.
4. Using the keyword union to declare union, the address of each member of the Union is the address of the Union object. The reason why they share an address is that the Union is also called a community. Therefore, only the value assigned to the union member is valid.

Object: objects are called objective objects in the real world. As long as they are objective objects, you can get abstract objects.
You can use the object name, attribute, and method to describe the object.
Like constructing enumeration and structure, a class is also a data type constructed by the user.
Create a new object type based on the existing object type. It inherits the features and functions of the original object. This idea is the main contribution of object-oriented design.

The process of generating a class from one or more previously defined classes is called derivation. This new class is also a derived class.
Inheritance refers to the features that the new class obtains from the base class, that is, the data functions that inherit the base class.

We can see that:
A class has better functions than a structure and has many properties. A class contains functions and can be viewed as a living creature. It can perform a series of actions or even inherit from it;
The structure seems to be a "Notebook", which only records some properties of objects.

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.