As the others have said, it's for type conversion, in this case to a bool
. For example:
class A {
bool isItSafe;
public:
operator bool() const
{
return isItSafe;
}
...
};
Now I can use an object of this class as if it's a boolean:
A a;
...
if (a) {
....
}