PHP object-oriented programming full Tutorial: 2. What is a class, what is an object, a class, and a pair

Source: Internet
Author: User
Class concept: A class is a set of objects with the same attributes and services. It provides a unified abstract description for all objects belonging to this class, which includes two main parts: attribute and service. In an object-oriented programming language, a class is an independent program unit. It should have a class name and contain two main parts: attribute description and service description. Object

Class concept: A class is a set of objects with the same attributes and services. It provides a unified abstract description for all objects belonging to this class, which includes two main parts: attribute and service. In an object-oriented programming language, a class is an independent program unit. It should have a class name and contain two main parts: attribute description and service description. Object

Class concept: A class is a set of objects with the same attributes and services.It provides a unified abstract description for all objects belonging to this class, which includes two main parts: attribute and service. In an object-oriented programming language, a class is an independent program unit. It should have a class name and contain two main parts: attribute description and service description.

Object: an object is an entity used to describe objective things in a system. It is a basic unit of a system.An object consists of a group of attributes and a group of services that operate on these attributes. From a more abstract point of view, an object is an abstraction of some things in the problem domain or implementation domain. It reflects the information that the things need to be stored in the system and its role; it is the encapsulation body of a set of attributes and a group of services that have the right to operate on these attributes. The objective world is composed of links between objects.

The relationship between a class and an object is like the relationship between a mold and a casting. The instantiation result of a class is an object, and the abstraction of A Class Object is a class.Class describes a group of objects with the same features (attributes) and the same behavior (methods. The above is probably their definition. Maybe you are a friend of an object just like an object. Don't get dizzy with the concept. Give you a column, if you want to buy several assembled PCs in Zhongguancun, what do you do when you get there? Are the installation engineers sitting with you, complete an installation configuration sheet with the information you provide. This configuration sheet can be imagined as a class, and it is a piece of paper, however, it records the information of the PC you want to buy. If you use this configuration item to buy 10 machines, the 10 machines are all composed of the configuration items, therefore, these 10 machines are of the same type or category. So what is an object? The instantiation result of the class is an object. The machine that is configured (instantiated) with this configuration sheet is an object, which is an object that we can operate on. There are 10 machines and sub-databases, 10 objects. Each sub-machine is independent and can only indicate that they are in the same category. Any action on one of the sub-machines will not affect the other nine machines, but I modify the class, that is to say, if one or fewer accessories are added to the configuration list, the nine hosts that have been installed are changed. This is the relationship between classes and objects (the instantiation result of classes is 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.