#include <iostream>
struct s
{
int i;
s(int j)
: i(j)
{ }
};
std::ostream& operator<<(std::ostream& outputstream, s& arr)
{
outputstream << arr.i << "\n";
return outputstream;
}
s operator+(const s& a, const s& b)
{
return s(a.i + b.i);
}
int main()
{
s m(1);
s n(2);
std::cout << (m + n);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgogCnN0cnVjdCBzCnsKICAgIGludCBpOwogICAgICAgIAogICAgICAgIHMoaW50IGopCiAgICAgICAgICAgICAgICA6IGkoaikKICAgICAgICB7IH0KICAgICAgICAKfTsKIAogCnN0ZDo6b3N0cmVhbSYgb3BlcmF0b3I8PChzdGQ6Om9zdHJlYW0mIG91dHB1dHN0cmVhbSwgcyYgYXJyKQp7CiAgICAgICAgb3V0cHV0c3RyZWFtIDw8IGFyci5pIDw8ICJcbiI7CiAgICAgICAgcmV0dXJuIG91dHB1dHN0cmVhbTsKfQogCnMgb3BlcmF0b3IrKGNvbnN0IHMmIGEsIGNvbnN0IHMmIGIpCnsKICAgIHJldHVybiBzKGEuaSArIGIuaSk7Cn0KIAppbnQgbWFpbigpCnsKICAgIHMgbSgxKTsKICAgIHMgbigyKTsKICAgIAogICAgc3RkOjpjb3V0IDw8IChtICsgbik7CiAgICByZXR1cm4gMDsKfQog
prog.cpp: In function 'int main()':
prog.cpp:30:24: error: cannot bind 'std::ostream' lvalue to 'std::basic_ostream<char>&&'
/usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/ostream:579:5: error: initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char, _Traits = std::char_traits<char>, _Tp = s]'