Home >Backend Development >C#.Net Tutorial >C++11 common syntax - specific usage of explicit type conversion operator
In order to think about the differences between the explicit type conversion operator and the C Primer book, and provide more meaningful examples, the author has spent a lot of thought, so please understand it carefully.
Type conversion operator
Look at the following example:
At this time, the prototype of a plural class, Defines a type conversion operator for double type. After you have it, you can use it like this:
Do you really want to convert to double?
Look at the following code again:Explicit type conversion operator
In order to eliminate ambiguity, one way is to use explicit to prohibit implicit double type conversion. The code is as follows:
Additional point
If you like, you can also encode it like this:HTML operators, type conversion
C# Custom implicit and explicit conversion
The above is the detailed content of C++11 common syntax - specific usage of explicit type conversion operator. For more information, please follow other related articles on the PHP Chinese website!