class Foo { public: operator std::string() const { return "I am a foo!"; } }; ... Foo foo; std::cout << foo; // Will print "I am a foo!".