5
为什么CL
实例到const int&
的转换在这里暧昧?模糊转换为参考
struct CL
{
operator const int&()
{
}
operator int&()
{
}
};
void fnc(const int&)
{
}
int main()
{
CL cl;
fnc(cl);
}
有两种方式:
1)。 cl.operator const int&()
导致用户定义的转换
2)。 cl.operator int&()
导致用户定义的转换和资格转换(0到const int&
)
第一种方式比第二种方式更好,不是吗?我看到标准版,但什么都没发现。