Whenever I try to compile my Song class I get a ton of linker error messages. I'm using the Dev-C++ compiler. Here's my code:
//The header file
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
class Song
{
public:
Song();
Song(string title, string artist, string album);
void setTitle(string aTitle);
void setArtist(string anArtist);
void setAlbum(string anAlbum);
string getTitle(); //to get the Song Title
string getArtist(); //to get artist name
string getAlbum(); //to get album name
bool operator==(const Song & otherSong);
bool operator>(const Song & otherSong);
string displayString();
private:
string songTitle;
string artistName;
string albumName;
};
//The implementation file
#include <string>
#include <iostream>
#include "Song.h"
using namespace std;
Song::Song(){
songTitle = "";
artistName = "";
albumName = "";
}
Song::Song(string title, string artist, string album){
songTitle = title;
artistName = artist;
albumName = album;
}
void Song::setTitle(string aTitle){
songTitle = aTitle;
}
void Song::setArtist(string anArtist){
artistName = anArtist;
}
void Song::setAlbum(string anAlbum){
albumName = anAlbum;
}
string Song::getTitle()
{
return songTitle;
}
string Song::getArtist()
{
return artistName;
}
string Song::getAlbum()
{
return albumName;
}
bool Song::operator==(const Song & otherSong){
bool status;
if(songTitle == otherSong.songTitle && artistName == otherSong.artistName && albumName == otherSong.albumName)
status = true; //to see if songs are equal
else
status = false;
return status;
}
bool Song::operator>(const Song & otherSong){
bool status;
}
if(albumName > otherSong.albumName)
status = true; //to compare songs lexicographically
else if(albumName == otherSong.albumName && songTitle > otherSong.songTitle)
status = true; //if album is the same, sort by song
return status;
}
string Song::displayString(){
string result = "\nTitle: " + songTitle;
result += "\nArtist: " + artistName;
result += "\nAlbum: " + albumName;
return result;
}