Can you use keyword explicit to prevent automatic conversion of method parameters?

后端 未结 8 1472
心在旅途
心在旅途 2020-12-04 17:18

I know you can use C++ keyword \'explicit\' for constructors of classes to prevent an automatic conversion of type. Can you use this same command to prevent the conversion

8条回答
  •  情深已故
    2020-12-04 18:23

    No. explicit prevents automatic conversion between specific classes, irrespective of context. And of course you can't do it for built-in classes.

提交回复
热议问题