次のクラス宣言があります。
class DepthDescriptor
{
public:
DepthDescriptor(DepthType depth);
bool operator==(DepthDescriptor& type);
bool operator>=(DepthDescriptor& type);
bool operator<=(DepthDescriptor& type);
...
}
DepthDescriptor演算子の比較ができるように、次の行がオブジェクトへの暗黙的な変換を実行しないのはなぜですか?
if (depth == Depth_8U)
{
...
}
depthはDepthDescriptorオブジェクトでDepthTypeあり、は列挙型でありDepth_8U、列挙値の 1 つであることに注意してください。上記のような行が最初に暗黙のコンストラクターを呼び出し、DepthDescriptor(DepthType depth)次に適切な演算子を呼び出すことを望んでいましたが、 no operator "==" matches these operands.