class A { public: //explicit A(int i){} A(int i){} }; void fun(const A& a) {} int main() { // If I use explicit for A constructor,I can prevent this mistake. // (Or shall I call it as feature?) fun(10); }
或者我应该允许隐式转换,以允许用户以较少的输入调用我的API?
P.S.:我现在似乎无法想出一个很好的例子,所以任何帮助都会受到赞赏.