Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <string>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- class Student
- {
- std::string name;
- std::string surname;
- int group;
- public:
- Student(char* name, char* surname, int group)
- : name(name),surname(surname),group(group)
- {}
- std::string getName() { return name; }
- std::string getSurname() { return surname; }
- int getGroup() { return group; }
- void setName(char* name) { this->name = std::string(name); }
- void setSurname(char* surname) { this->surname = std::string(surname); }
- void setGroup(int group) { this->group = group; }
- friend std::ostream& operator<<(std::ostream& os, Student& s);
- bool operator <(Student & other)
- {
- if (group == other.group)
- {
- if (surname == other.surname)
- {
- return name < other.name;
- }
- else {
- return surname < other.surname;
- }
- }
- else {
- return group < other.group;
- }
- }
- bool operator ==(Student & other)
- {
- return group == other.group && surname == other.surname && name == other.name;
- }
- bool operator> (Student& other)
- {
- if (*this == other)
- {
- return false;
- }
- else {
- return !(*this < other);
- }
- }
- };
- std::ostream& operator<<(std::ostream& os, Student& s)
- {
- return os << s.group << "\t" << s.surname << "\t" << s.name << std::endl;
- }
- typedef std::vector<Student> Group;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement