Study day 46



1. Constructor
    	1. For a special member in a class, its name is the same as the class name. When creating a class object, the special member will be automatically called by the system
    	2. Forget to call manually
    	3. The purpose is to initialize the data members of class objects
    	4. The constructor has no return value, there is no void before the constructor, there is nothing in front of the constructor, the function name starts directly
    	5. Constructors cannot be called manually
    	6. The constructor should be declared as public, because it will be called when it is created, and it is a private member by default
    	7. Cannot call constructor directly
2. Multiple constructors
   	1. A class can have multiple constructors and provide multiple initialization methods for multiple class objects
   	2. Copy constructor, initialize another object with one object
3. Function default parameters
   	1. The default value can only be placed in the function declaration, unless the function has no declaration
   	2. When defining a default value in a function with multiple parameters, the default value must appear on the right side of the non default function. Once a parameter begins to specify a default value, the parameter on the right side must specify a default value
   	3. In the function definition of multiple parameters, the former function has default value, and the latter parameter must have default value
4. Implicit transformation and explicit
   	1. Explicit in the constructor declaration means that the constructor can only be used to initialize and display type conversions
   	2. For single parameter constructors, it is recommended to use explicit to declare
5. Constructor initialization list
   	1. The beginning of a separate colon, the middle of which is the member name, the end of which is in brackets, and the initial value in brackets

Recommended Today

Rust and python: why rust can replace Python

In this guide, we compare the rust and python programming languages. We will discuss the applicable use cases in each case, review the advantages and disadvantages of using rust and python, and explain why rust might replace python. I will introduce the following: What is rust? What is Python? When to use rust When to […]