News for hackers. Stuff that matters.
Re:Write a program that makes 2 + 2 = 5 by boost_ on Sunday June 01, 2014 @03:30PM (#7830320)
first thing i thought when i read the title:

    #include <iostream>

    class Int
    {
    private:
            int _value;

    public:
	    Int(int value) : _value(value) {}
	    Int operator + (const Int& b){ return Int(++_value + b._value); }
	    friend std::ostream& operator << (std::ostream& out, const Int& value){ out << value._value; return out; }
    };

    int main(int argc, char** argv)
    {
	    std::cout << Int(2) + Int(2) << std::endl;
            return 0;
    }
output: 5

There are no comments on this comment yet.