An implicit type conversion operator is simply a member function with a strange-looking name: the word operator
followed by a type specification. You aren't allowed to specify a type for the function's return value, because the type of the return value is basically just the name of the function.
Item 5:Be wary of user-defined conversion functions.(More Effective C++)
转载
Two kinds of functions allow compilers to perform such conversions: single-argument constructors and implicit type conversion operators. A single-argument constructor is a constructor that may be called with only one argument. Such a constructor may declare a single parameter or it may declare multiple parameters, with each parameter after the first having a default value.
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
More Effective C++:异常
强制性:异常不能被忽略,这与传统的错误代码不同,后者可能被忽略。安全性:异常确保了错误状态被正确处理,而非让
c++ 抛出异常 析构函数 构造函数