Constructor

xiaoxiao2021-03-06  139

The constructor is automatically called when the object is created, especially the constructor is the same name.

The constructor is automatically called by the system when defining the class object, and the destructor is a member function that is automatically called by the system when the class object is released.

(1) The constructor is a member function that is the same as the class of the class.

(2) The constructor has no return value, nor does the VOID type.

(3) The constructor can be overloaded.

(4) The role of constructor is to assign initial values ​​for data members of the class object.

(5) The constructor is automatically called by the system when defining a class object, and is not allowed by the user directly like other member functions.

(6) Constructor is generally a public member of the class.

(7) System default constructor is x () {}.

转载请注明原文地址:https://www.9cbs.com/read-126989.html

New Post(0)