Implicit conversion to std::string [duplicate]
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Overload resolution failure when streaming object via implicit conversion to string I know it's not such a good idea to do this, but I really want to know the reason why the code below does not compile (i.e. why there is "no acceptable conversion"): #include <iostream> #include <string> class Test { public: operator std::string () const; }; Test::operator std::string () const { return std::string("Test!"); } int