Advertisement
Guest User

Untitled

a guest
Mar 21st, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #pragma once
  2. #include <string>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. class Student
  7. {
  8. std::string name;
  9. std::string surname;
  10. int group;
  11. public:
  12. Student(char* name, char* surname, int group)
  13. : name(name),surname(surname),group(group)
  14. {}
  15. std::string getName() { return name; }
  16. std::string getSurname() { return surname; }
  17. int getGroup() { return group; }
  18. void setName(char* name) { this->name = std::string(name); }
  19. void setSurname(char* surname) { this->surname = std::string(surname); }
  20. void setGroup(int group) { this->group = group; }
  21. friend std::ostream& operator<<(std::ostream& os, Student& s);
  22. bool operator <(Student & other)
  23. {
  24. if (group == other.group)
  25. {
  26. if (surname == other.surname)
  27. {
  28. return name < other.name;
  29. }
  30. else {
  31. return surname < other.surname;
  32. }
  33. }
  34. else {
  35. return group < other.group;
  36. }
  37. }
  38.  
  39. bool operator ==(Student & other)
  40. {
  41. return group == other.group && surname == other.surname && name == other.name;
  42. }
  43. bool operator> (Student& other)
  44. {
  45. if (*this == other)
  46. {
  47. return false;
  48. }
  49. else {
  50. return !(*this < other);
  51. }
  52. }
  53. };
  54. std::ostream& operator<<(std::ostream& os, Student& s)
  55. {
  56. return os << s.group << "\t" << s.surname << "\t" << s.name << std::endl;
  57. }
  58.  
  59. typedef std::vector<Student> Group;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement