fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Movie {
  6. public:
  7. Movie(string movieTitle);
  8. void SetUpVotesAndDownVotes(int numUpVotes, int numDownVotes) {
  9. upVotes = numUpVotes;
  10. downVotes = numDownVotes;
  11. }
  12. string GetTitle() const { return title; }
  13. int GetUpVotes() const { return upVotes; }
  14. int GetDownVotes() const { return downVotes; }
  15.  
  16. private:
  17. string title;
  18. int upVotes;
  19. int downVotes;
  20. };
  21.  
  22. Movie::Movie(string movieTitle) {
  23. title = movieTitle;
  24. upVotes = 0;
  25. downVotes = 0;
  26. }
  27.  
  28. bool operator==(const Movie& movie1, const Movie& movie2) {
  29. return movie1.GetDownVotes() == movie2.GetDownVotes();
  30. }
  31.  
  32. int main() {
  33. Movie movie1("Up");
  34. Movie movie2("Taken");
  35.  
  36. movie1.SetUpVotesAndDownVotes(8, 2);
  37. movie2.SetUpVotesAndDownVotes(8, 2);
  38.  
  39. if (movie1 == movie2) {
  40. cout << "Equal" << endl;
  41. }
  42. else {
  43. cout << "Not equal" << endl;
  44. }
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Equal