【发布时间】:2011-06-29 03:21:44
【问题描述】:
以下是测试代码:
struct A
{
operator int ();
operator int () const;
};
void foo (const int);
现在,在调用时:
foo(A()); // calls A::operator int()
为什么是always chooses the non-const version?即使创建operator const int () const; 对调用foo() 也没有任何影响。除了标准参考之外,有人可以从逻辑上解释其背后的原因吗?
【问题讨论】:
标签: c++ constants overloading overload-resolution