From: Huang Bongyong Handsome
1. When a constructor with one parameter is in the class, an implicit conversion of the holding object, such as a Class A, and a constructor with a parameter, a (int i) {}, is invoked when statement a m=1 is present, and a constructor with one argument is called to create the object m, that is, to convert the statement to a M (1).
2. If there is a function such as void F (A J) {} This function requires an object of Class A as a parameter, but when the call statement is F (2), the function can also be called, when the function's formal parameter A J is interpreted as a j=2 that implicitly invokes a constructor with one argument to create an object J.
However, there is a form of function definition when a call such as the statement F (2) error occurs, that is, the function f definition of void F (A &j) {} defines a reference to accept an argument error, the reason is unclear. In these cases, however, void F (A J) {},void F (const a J) {};void F (Consta & j) {} is correctly called.
3. If this implicit type conversion is not required, the explicit is used before the constructor, and the closing word can only be used before the constructor. If explicit is used before the constructor, statements A M=1 and F (2) will have an error.
4. A constructor declared as explicit cannot be used in an implicit conversion.
"C + +" implicit type conversion and explicit keywords