Jun 15, 2013 at 12:54pm UTC
Write your question here.
Hey, i made a list of classes using the stl. but when i am trying remove an element or find an elevent i'm getting this error: error C2678: binary '==' : no operator found which takes a left-hand operand of type 'Song' (or there is no acceptable conversion.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#ifndef Song_h
#define song_h
#include<iostream>
#include<string>
#include <queue>
using namespace std;
enum eSection{ INTRO, VERSE, CHORUS, TRANSITION };
enum eSectionDurationInSeconds{ INTOR_DUR = 5, VERSE_DUR = 10, CHORUS_DUR = 20, TRANSITION_DUR = 5 };
class Song{
private :
string m_songName; // Song Name.
string m_composerName; // Song Composer
string m_singerName; // The singer, could be more than one.
queue<string> m_songStructure;
public :
Song(string songName = "Not Set Yet" , string composerName = "Not Set Yet" , string singerName = "Not Set Yet" );
~Song();
void set(); // ?
string getSongName();
void addSection(const eSection sec, const eSectionDurationInSeconds iDuration);
const void playSong() const ;// Function Plays the Song.
const double getSongLenghtInMinutes() const ;
};
#endif
none of this work:
1 2 3 4 5 6 7
bool Playlist::isSongInPlaylist( const Song& song ){
list<Song>::iterator iter = find(m_songList.begin(),m_songList.end(),song);
}
void Playlist::removeSongFromPlaylist(const Song& song){
m_songList.remove(song);
}
Last edited on Jun 15, 2013 at 12:55pm UTC
Jun 15, 2013 at 1:41pm UTC
You did not define operator == for class Song. So the compiler does not know how to compare objects of type Song.