midoking

Song.cpp

Oct 13th, 2022
848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include "Song.h"
  2.  
  3. Song::Song() : name { "unknown" }, artist{ "unknwon" }, rating(0) {}
  4.  
  5. Song::Song(std::string n, std::string a, int c) : name(n), artist(a), rating(c) {}
  6.  
  7. // getters
  8.  
  9. int Song::getRating() const {
  10.     return rating;
  11. }
  12.  
  13. std::string Song::getName() const {
  14.     return name;
  15. }
  16. std::string Song::getArtist() const {
  17.     return artist;
  18. }
  19.  
  20. //
  21.  
  22. // overloaded functions
  23.  
  24. bool Song::operator==(const Song& rhs) const {
  25.     return (this->name == rhs.name) && (this->rating == rhs.rating);
  26. }
  27.  
  28. bool Song::operator<(const Song& rhs) const {
  29.     return this->rating < rhs.rating;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment