Reputation: 25
I'm using private enum class in nested class and want to implement operator! for my enum class.
I know how to do this. But when I tried to overlord operator of enum class in nested class, compiler treats my operator as an operator of class, not for enum class.
class test{
private:
enum class Loc : bool{
fwrd = true,
bkrd = false
};
Loc Loc::operator!(){ //error msg 1.
return Loc(!bool(*this));
}
Loc operator!(){
return something; //this treated as test's operator
}
Loc doSomething(Loc loc){
return !loc; //error msg 2.
}
}
enum class Other : bool{
fwrd = true,
bkrd = false
};
Other operator!(Other o){ //this works
return Other(!bool(*this));
}
Error msgs
Upvotes: 2
Views: 1463