Как правильно реализовать оператор для класса:
Department operator+=(Course &);
Сам класс:
using namespace std;
class Student;
class Course;
class Department
{
// overload input output streams
friend ostream &operator<<(ostream &, const Department &);
friend istream &operator>>(istream &, Department &);
private:
string name;
long id;
Course** coursesOfDepartment; // list of pointers course in this department
Student** studendOfDepartment; // list of pointers studetns of this department
Student** badStudentsOfDepartment; // list of point students by the course points < 65
public:
static int departmentsCounter; // count num of elements
Department();
// set get block
void setId(long);
void setName(string);
string getName() { return name; }
long getId() { return id; }
// overload block
Department &operator=(const Department &); // instead copy constructor
bool operator>(const Department &) const; // check if count of students greater than count of students in another department
Department operator+=(Course &); // add new course to to the department list
Department operator+=(Student &); // add new student to to the department list
~Department();
};
В операторе нужно создать новый объект класса Course
и добавить его в массив Course** coursesOfDepartment
.
main
, простите?