There is a student structure:
struct Stud { string firstName; string secondName; int averageScore; }; There is a class Group:
class Group { private: string nameGroup; vector<Stud> students; public: ... } Sort in main:
vector<Group> groups; sort(groups.begin(), groups.end()); copy(groups.begin(), groups.end(), ostream_iterator<Group>(cout)); Overloaded the output statement:
const string& Group::getNameGroup()const { return nameGroup; } void Group::outputStudents(ostream& out)const { copy(students.begin(), students.end(), ostream_iterator<Stud>(out, " ")); } ostream& operator <<(ostream& out, const Group& group) { out << group.getNameGroup(); group.outputStudents(out); return out; } ostream& operator <<(ostream& out, const Stud& stud) { out << "\t" << stud.firstName << "\t" << stud.secondName << "\t" << stud.averageScore<<"\n"; return out; } After execution, sort displays only the name of the group and refers to
void Group::outputStudents(ostream& out)const { copy(students.begin(), students.end(), ostream_iterator<Stud>(out, " ")); } Writes that vector iterators are incompatible. Sorry for the trouble, maybe everything is obvious, but I'm new to C ++ and I can’t understand what the error is.