Clion提示:Single-argument constructors must be marked explicitly to avoid unintentional implicit conversions 解法办法

参考:https://www.cnblogs.com/xudong-bupt/p/3671972.html

在写一个类的时候,如果一个构造器是接收单个参数的,那么最好要加上explicit。
如果不加的话,该构造函数还会拥有类型转换的情形,造成混淆。

解决办法:该构造函数的声明前加上explicit。

猜你喜欢

转载自www.cnblogs.com/theodoric008/p/9465673.html