User Defined Conversions in C++

前端 未结 4 1986
遥遥无期
遥遥无期 2020-12-10 14:07

Recently, I was browsing through my copy of the C++ Pocket Reference from O\'Reilly Media, and I was surprised when I came across a brief section and example regard

4条回答
  •  时光取名叫无心
    2020-12-10 14:41

    It's not particularly obscure; it is very portable (it is part of the language after all), and conversion to user-defined types is possible.

    One word of caution, having a lot of possible implicit conversion paths can lead to unexpected conversion being invoked and surprising bugs. Also, having non-explicit converting constructors and conversion functions between several user-defined types can lead to more ambigious conversion sequeunces which can be a pain to resolve.

提交回复
热议问题