c++ – How can I make (x==1 && x==2 && x==3 && x==4) return true?

Question:

A funny C++ question was asked today – how to achieve that

(x==1 && x==2 && x==3 && x==4) 

was true ?

Answer:

Like that

class X {
    public:
    bool operator==(int other) {
        return true;
   }
}

x = X();
Scroll to Top