Preliminary understanding of classes and objects

Source: Internet
Author: User

For beginners, objects and classes tend to be confusing.

For example: I want to buy a TV, so TV is a class or an object? A single dog, a daughter-in-law is a class or object? Am I a class or an object? Wait a minute.

Let's look at one explanation:

A class is an abstraction of an object that is a concrete instance of a class.

The class is abstract and does not exist, and in computer language it does not occupy memory. The object is specific and occupies a memory space.

Finally, two examples are used to illustrate their relationship:
For example: The class is the fruit, the object is Apple .
Another example is "Human" is a class, then the specific person "Zhang San" is "human" this class of objects,
The "name, age" and other information is the property of the object, human actions such as "eating, dressing" and so on is the object of the method.
Always the same is the set of things with the same characteristics, and the object is a concrete instance of the class.
At the same time, the class has polymorphism and inheritance, such as "human" can be divided into "man, Woman", "Old man, child" then "man, Woman" is the "human" sub-category and so on.
Finally, if you do not understand, you can communicate with me ...

Preliminary understanding of classes and 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.