```
#include <iostream>
#include <sstream>
#include <QString>
class Printer {
public:
inline std::ostream& operator<<(const std::string& str) {
stream << str;
return stream;
}
inline std::ostream& operator<<(int numb) {
stream << numb;
return stream;
}
inline std::ostream& operator<<(const QString& str) {
stream << str.toStdString();
return stream;
}
virtual ~Printer(void) {
std::cout << stream.str();
}
private:
std::stringstream stream;
};
int main(void)
{
QString qstring("qstring");
std::string stdstring("std::string");
Printer() << qstring << stdstring << 1; // Works like charm
Printer() << stdstring << qstring << 1; // Doesnt work :(
return 0;
}
```
任何人都可以看看上面的代码并告诉我主要方法中的问题是什么我有评论