class与constructor

  • constructor在一个对象被new时执行
  • When the constructor may be omitted, omit the new new instance of the object constructor, assignment to all data types 0, bool type assignment is FALSE, the reference type assigned to NULL.
  • Constructors have the same name as the class, and can not have a return type. The method is the same name as the class, but must declare the return data type.
  • When the first object is a new call to a static original data block (may be omitted), and then call the parent class constructor (not not called a subclass), the last constructor calls itself (certain calls), so as to create an instance of an object.
  • Constructors can be overloaded, overload requirements are different parameters.

Guess you like

Origin blog.csdn.net/weixin_44018338/article/details/91621998