私はこのようなコードスニペットを持っています:
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<< ...'
このコードの何が問題になっているのか教えていただけますか?