I have song list, where song is an object, songName and songArtist are both song's attributes; I need to order them alphabetically according to name or artist, depends on the user; I want to overload >
operator to do so, but I wanted to know if I can kind of add a flag to identify if user wants to order them according to the name of the song or the artist name.
bool Song::operator > (const Song& s, const bool& flag){
if(flag)
return songName> s.songName;
else
return songArtist> s.songArtist;
}
And if so, how can I make the comparison? I mean, where would the flag be if my evaluation is like if(song>s.song)
?