What is a class? What is an object? What is the relationship between a class and an object?

Source: Internet
Author: User

Object-oriented (Oriented,oo).

At first, "object-oriented" refers to the design method of encapsulation, inheritance and polymorphism in the programming. Now, object-oriented thinking has involved all aspects of software development. For example, object-oriented analysis (ooa,objectoriented analyses), object-oriented design (Ood,object oriented), and object-oriented programming implementations (Oop,object oriented Programming).

Object and Class Interpretation:

1) Object: object is anything that people want to study, it can not only express the concrete things, but also can represent abstract rules, plans or events. An object has a state, and an object uses data values to describe its state. Objects also have actions that change the state of an object, and the object and its operations are the object's behavior. Objects enable data and operations to be combined to encapsulate data and operations in the unity of the object.

2) Class: An abstraction of an object with the same attribute (data element) and behavior (function) is the class. Thus, an object's abstraction is a class, the materialization of a class is an object, or an instance of a class is an object, and a class is actually a data type. A class has attributes, which are abstractions of the state of an object, and data structures that describe the properties of a class. A class has an operation that is an abstraction of the behavior of an object, described by the operation name and the method that implements it.

Relationship of objects and classes:

The relationship between a class and an object is like the relationship between a mold and a casting, and the result of the strength of the class is the object, and the abstract of the object is the class, which describes a set of objects that have the same attributes (attributes) and the same behavior.

Class person{}//This is classes $obj = new person ();//The instantiation of the class is the object
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.