#include <iostream>
#include <fstream>
class my_ostream
{
public:
my_ostream() : my_fstream("some_file.txt") {}; // check if opening file succeeded!!
// for regular output of variables and stuff
template<typename T> my_ostream& operator<<(const T& something)
{
std::cout << something;
my_fstream << something;
return *this;
}
// for manipulators like std::endl
typedef std::ostream& (*stream_function)(std::ostream&);
my_ostream& operator<<(stream_function func)
{
func(std::cout);
func(my_fstream);
return *this;
}
private:
std::ofstream my_fstream;
};
my_ostream mout;
int main()
{
mout << "Hello Worlds!" << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KCmNsYXNzIG15X29zdHJlYW0KewpwdWJsaWM6CiAgbXlfb3N0cmVhbSgpIDogbXlfZnN0cmVhbSgic29tZV9maWxlLnR4dCIpIHt9OyAvLyBjaGVjayBpZiBvcGVuaW5nIGZpbGUgc3VjY2VlZGVkISEKICAvLyBmb3IgcmVndWxhciBvdXRwdXQgb2YgdmFyaWFibGVzIGFuZCBzdHVmZgogIHRlbXBsYXRlPHR5cGVuYW1lIFQ+IG15X29zdHJlYW0mIG9wZXJhdG9yPDwoY29uc3QgVCYgc29tZXRoaW5nKQogIHsKICAgIHN0ZDo6Y291dCA8PCBzb21ldGhpbmc7CiAgICBteV9mc3RyZWFtIDw8IHNvbWV0aGluZzsKICAgIHJldHVybiAqdGhpczsKICB9CiAgLy8gZm9yIG1hbmlwdWxhdG9ycyBsaWtlIHN0ZDo6ZW5kbAogIHR5cGVkZWYgc3RkOjpvc3RyZWFtJiAoKnN0cmVhbV9mdW5jdGlvbikoc3RkOjpvc3RyZWFtJik7CiAgbXlfb3N0cmVhbSYgb3BlcmF0b3I8PChzdHJlYW1fZnVuY3Rpb24gZnVuYykKICB7CiAgICBmdW5jKHN0ZDo6Y291dCk7CiAgICBmdW5jKG15X2ZzdHJlYW0pOwogICAgcmV0dXJuICp0aGlzOwogIH0KcHJpdmF0ZToKICBzdGQ6Om9mc3RyZWFtIG15X2ZzdHJlYW07Cn07CgpteV9vc3RyZWFtIG1vdXQ7CgppbnQgbWFpbigpCnsKICBtb3V0IDw8ICJIZWxsbyBXb3JsZHMhIiA8PCBzdGQ6OmVuZGw7Cn0=