当类较多且经常需要进行类型之间的转换时,定义类型转换操作符还是很方便的。
A conversion operator provides a way for you to define how an object can be converted automatically to a different type.
隐式转换操作符将 Point 类型转换为 int。
The implicit conversion operator is defined, which converts a Point type to int.
定义转换操作符来简化数字类型之间的缩小和放大转换。
Define conversion operators to simplify narrowing and widening conversions between numeric types.
应用推荐