c++ – How do I get (x == 1 && x == 2 && x == 3 && x == 4) to return true?

Question:

Today they asked a funny question about C ++ – 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