#include <iostream> #include <array> #include <algorithm> using namespace std; class AcademicDiscipline { string Name; int NumberOfSem; string LessonType; int Hours; string ControlType; array <string, 3> Instructors; public: AcademicDiscipline(string Name, int NumberOfSem, string LessonType, int Hours, string ControlType, array <string, 3> Instructor): Name(Name), NumberOfSem(NumberOfSem), LessonType(LessonType), Hours(Hours), ControlType(ControlType), Instructors(Instructor) { } AcademicDiscipline(const AcademicDiscipline &other) { *this = other; } string getName() const { return Name; } int getSemNumber() const { return NumberOfSem; } string getLessonType() const { return LessonType; } int getHours() const { return Hours; } string getControlType() const { return ControlType; } string getInstructors() const { string result; // for(int i =0; i<Instructors.size(); i++) // { // result += Instructors[i] + '; '; // } for(auto &elem: Instructors) { result += "Name: " + elem + "; ";} return result; } AcademicDiscipline& operator=(const AcademicDiscipline& other){ if (this != &other) { this->Name = other.Name; this->NumberOfSem = other.NumberOfSem; this->LessonType = other.LessonType; this->Hours = other.Hours; this->ControlType = other.ControlType; this->Instructors = other.Instructors; } return *this; } bool operator==(const AcademicDiscipline& other){ bool res; if (this -> Name == other.Name and this -> NumberOfSem == other.NumberOfSem) { res = true; } res = false; return res; } bool operator !=(const AcademicDiscipline& other) { return !(*this == other); } ostream& operator << (ostream& os, const AcademicDiscipline &obj) { os << "Discipline: " << obj.getName() << ", Number of semester: " << obj.getSemNumber(); os << "\nLesson type" << obj.getLessonType() << ", Control type: " << obj.getControlType(); os << "\nAmount of hours: " << obj.getHours(); os << "\nInstructors: " << obj.getInstructors(); return os; } void AddInstructor(string NewName){ Instructors.fill(NewName); } void CorrectInstructor(string PrevName, string NewName){ for (auto &elem: Instructors){ if (elem.data() == PrevName){ elem = NewName; } } } ~AcademicDiscipline(){ } }; int main(){ array <string,3> proff; proff.fill("Ivanov Ivan Ivanovich"); proff.fill("Petrov Petr Petrovich"); string disc_name = "C++"; string lesson = "lection"; string control = "exam"; AcademicDiscipline disc(disc_name, 1, lesson, 60, control, proff); AcademicDiscipline yet_another_disc(disc); cout << disc; disc.AddInstructor("Semenov Semen Semenovich"); disc.CorrectInstructor("Petrov Petr Petrovich", "Sidorov Sidor Sidorovich"); int res; cin >> res; return res; }
Standard input is empty
In file included from prog.cpp:2: In file included from /usr/bin/../lib/gcc/i586-linux-gnu/4.9/../../../../include/c++/4.9/array:35: /usr/bin/../lib/gcc/i586-linux-gnu/4.9/../../../../include/c++/4.9/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. #error This file requires compiler and library support for the \ ^ prog.cpp:12:5: error: unknown type name 'array' array <string, 3> Instructors; ^ prog.cpp:12:11: error: expected member name or ';' after declaration specifiers array <string, 3> Instructors; ~~~~~ ^ prog.cpp:16:24: error: unknown type name 'array' array <string, 3> Instructor): ^ prog.cpp:16:30: error: expected ')' array <string, 3> Instructor): ^ prog.cpp:15:23: note: to match this '(' AcademicDiscipline(string Name, int NumberOfSem, string LessonType, int Hours, string ControlType, ^ prog.cpp:84:14: error: overloaded 'operator<<' must be a binary operator (has 3 parameters) ostream& operator << (ostream& os, const AcademicDiscipline &obj) { ^ prog.cpp:18:25: error: use of undeclared identifier 'Instructor'; did you mean 'AddInstructor'? Instructors(Instructor) ^~~~~~~~~~ AddInstructor prog.cpp:92:10: note: 'AddInstructor' declared here void AddInstructor(string NewName){ ^ prog.cpp:18:13: error: member initializer 'Instructors' does not name a non-static data member or base class Instructors(Instructor) ^~~~~~~~~~~~~~~~~~~~~~~ prog.cpp:52:13: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions] for(auto &elem: Instructors) ^ prog.cpp:52:23: warning: range-based for loop is a C++11 extension [-Wc++11-extensions] for(auto &elem: Instructors) ^ prog.cpp:52:25: error: use of undeclared identifier 'Instructors'; did you mean 'getInstructors'? for(auto &elem: Instructors) ^~~~~~~~~~~ getInstructors prog.cpp:46:12: note: 'getInstructors' declared here string getInstructors() const { ^ prog.cpp:52:25: error: reference to non-static member function must be called; did you mean to call it with no arguments? for(auto &elem: Instructors) ^~~~~~~~~~~ () prog.cpp:53:30: warning: adding 'char' to a string does not append to the string [-Wstring-plus-int] { result += "Name: " + elem + "; ";} ~~~~~~~~~^~~~~~ prog.cpp:53:30: note: use array indexing to silence this warning { result += "Name: " + elem + "; ";} ^ & [ ] prog.cpp:53:37: error: invalid operands to binary expression ('const char *' and 'const char *') { result += "Name: " + elem + "; ";} ~~~~~~~~~~~~~~~ ^ ~~~~ prog.cpp:64:19: error: no member named 'Instructors' in 'AcademicDiscipline' this->Instructors = other.Instructors; ~~~~ ^ prog.cpp:64:39: error: no member named 'Instructors' in 'AcademicDiscipline' this->Instructors = other.Instructors; ~~~~~ ^ prog.cpp:93:9: error: use of undeclared identifier 'Instructors'; did you mean 'getInstructors'? Instructors.fill(NewName); ^~~~~~~~~~~ getInstructors prog.cpp:46:12: note: 'getInstructors' declared here string getInstructors() const { ^ prog.cpp:93:9: error: reference to non-static member function must be called; did you mean to call it with no arguments? Instructors.fill(NewName); ^~~~~~~~~~~ () prog.cpp:93:21: error: no member named 'fill' in 'std::basic_string<char>' Instructors.fill(NewName); ~~~~~~~~~~~ ^ prog.cpp:97:13: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions] for (auto &elem: Instructors){ ^ prog.cpp:97:23: warning: range-based for loop is a C++11 extension [-Wc++11-extensions] for (auto &elem: Instructors){ ^ prog.cpp:97:25: error: use of undeclared identifier 'Instructors'; did you mean 'getInstructors'? for (auto &elem: Instructors){ ^~~~~~~~~~~ getInstructors prog.cpp:46:12: note: 'getInstructors' declared here string getInstructors() const { ^ prog.cpp:97:25: error: reference to non-static member function must be called; did you mean to call it with no arguments? for (auto &elem: Instructors){ ^~~~~~~~~~~ () prog.cpp:98:20: error: member reference base type 'char' is not a structure or union if (elem.data() == PrevName){ ~~~~^~~~~ fatal error: too many errors emitted, stopping now [-ferror-limit=] 5 warnings and 20 errors generated.
Standard output is empty