In C ++, the constructor has a special initialization method called "initial expression table (initialization table)", which is located after the parameter table of the function, but before the function body, this indicates that the initialization in the table is prior to any code in the function body being executed. The constructor initialization list starts with a colon, followed by a list of data members separated by commas (,). Each data member is followed by an initialization formula in parentheses. Rules:
1. If the class has an inheritance relationship, the derived class must call the base class constructor in its initialization table.
2. Const constants of classes can only be initialized in the initialization table, because they cannot be initialized in the function body by assigning values.
3. Class data member initialization can be completed in the function body or in the initialization table, but the efficiency is different:
1. Non-Internal data types (custom data types) are more efficient when initializing tables.
2. Internal data types (such as int and float) have almost the same efficiency, but the function body assignment makes the program clearer and easier to read.