나는 음악 앨범을 다루는 Class
이있다. artists
및 albums
은 strings
입니다. 또한 contents
트랙 컬렉션 (vector
)이 있습니다. 각 트랙은 title
및 duration
입니다.C++ ostream << 연산자
이것은 내 ostream <<
:
ostream& operator<<(ostream& ostr, const Album& a){
ostr << "Album: " << a.getAlbumTitle() << ", ";
ostr << "Artist: " << a.getArtistName() << ", ";
ostr << "Contents: " << a.getContents() << ". "; //error thrown here
return ostr;
}
<<
a.getContents()
옆에 밑줄을 말한다되어 "Error: no operator "<<" matches these operands.
내가 무엇을 놓치고 또는 잘못된거야? 이 방법으로 벡터를 사용할 수 있습니까? 아니면 Track 클래스에서 빠진 내용 일 수도 있습니다. Album::getContents()
반환 std::vector<Track>
가정
'Album :: getContents()'는 무엇을 반환합니까? – juanchopanza
'getContents'는 무엇을 반환합니까? –