我有一个这样的代码片段:
class track {
public:
struct time {
unsigned minutes, seconds;
std::ostream& operator<<(std::ostream& o) {
o << minutes << "minute(s) " << seconds << " second(s)";
return o;
}
};
...
std::ostream& operator<<(std::ostream& o) {
o << "title: " << title << " performer: " << performer << " length: " << length << std::endl;
return o;
}
private:
std::string performer, title;
time length;
};
但是,如果我编译这段代码,我得到了这个错误:
no match for 'operator<< ...'
你能告诉我这段代码有什么问题吗?