Note: Traditional for statements run with subscripts. Foreach runs elements directly, so define “X” like any other object in array

1. Object-oriented programming ideas from life, everything is an object.

To describe any object in the world you can describe it in terms of static properties and dynamic properties 1, 2. To define a class is to define a new data type. 3. A class is an instance template of a concrete object.

The constructor has the same name as the class and returns no value

When there is no custom constructor, the system automatically creates a function with no arguments. 2

This refers to the current instance object.

4. Object-oriented three features: encapsulation, inheritance, polymorphism.

Note that member variables become properties once they have set and get!

Static properties: Member variables Dynamic properties: method functions ↩︎ But once a custom constructor with parameters is defined, the system will not create constructors. Therefore, in future development, it is recommended that any constructor that writes arguments must write a no-argument constructor. ↩ ︎ *