|
|
|
|
|
by boost_
4394 days ago
|
|
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 |
|