operator bool
oneと oneを使用してクラスを作成しようとしましたoperator void*
が、コンパイラーはあいまいだと言います。使用する演算子をコンパイラに説明する方法はありますか、または両方を使用できないのですか?
class A {
public:
operator void*(){
cout << "operator void* is called" << endl;
return 0;
}
operator bool(){
cout << "operator bool is called" << endl;
return true;
}
};
int main()
{
A a1, a2;
if (a1 == a2){
cout << "hello";
}
}