struct A
{
// error C2216: 'explicit' cannot be used with 'virtual'
virtual explicit operator bool() const
{
return true;
}
};
struct B : A
{
// error C2216: 'explicit' cannot be used with 'override'
explicit operator bool() const override
{
return false;
}
};
int main()
{
if (A())
{}
if (B())
{}
}
我的编译器是VC++ 2013 RC。
explicit
为什么与virtual
不兼容呢?
其中的原理是什么?