0

mySongsユーザーが入力した曲のコレクションを格納するベクトルです。if ステートメントでは、プログラムはベクトル内の要素をユーザー入力でチェックします。一致する場合、その指定された値をベクターから削除します。解決策を探すと、remove/erase idiom:の使用を推奨する人がいます。しかし、コードに実装すると、このエラーがポップアップし続けますC2678 binary '==': no operator found which takes a left - hand operand of type 'Song' (or there is no acceptable conversion)

void deleteSong() {
    string songTitle;

    cout << "\n\t\tPlease enter the particular song name to remove: ";
    cin >> songTitle;

    if (songTitle != "") {
        for (Song songs : mySongs) {
            if (songs.title == songTitle) {
                mySongs.erase(find(mySongs.begin, mySongs.end, songs));  //erase an element with value
                break;
            }
        }
    }
}
4

1 に答える 1