2. Only when the object is created will the constructor be selectively called according to the given parameters and the constructor definition in the class. If no constructor is defined in the class, by default, an empty constructor with no parameters will be provided. Other functions are called according to the programmer's requirements and must be explicitly called.
3. After the object is created, the system must return the address of the newly created object and assign it to the pointer variable (the reference in C++ is assigned to the object variable in C#, in fact, it also contains the object address), so the constructor cannot return any type of value, and all the definition compilers with return value constructors will not pass. The result is that constructors do not and cannot have return types, while other functions are arbitrary.
Extended data
Constructor memory mechanism
In Java, C# and VB. NET, constructors create instances as reference types in a special data structure called heap. Value types (such as int, double, etc. ) is created in an ordered data structure called a stack.
VB。 NET and C# will allow new to create instances of value types. However, in these languages, even objects created in this way will only exist on the stack.