{"action":"created","issue":{"url":"https://api.github.com/repos/Andrey540/faststart_Egoshin_Andrey/issues/16","labels_url":"https://api.github.com/repos/Andrey540/faststart_Egoshin_Andrey/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/Andrey540/faststart_Egoshin_Andrey/issues/16/comments","events_url":"https://api.github.com/repos/Andrey540/faststart_Egoshin_Andrey/issues/16/events","html_url":"https://github.com/Andrey540/faststart_Egoshin_Andrey/issues/16","id":56923122,"number":16,"title":"Замечания по лабораторной работе 5 задание 2","user":{"login":"alexey-malov","id":6040682,"avatar_url":"https://avatars.githubusercontent.com/u/6040682?v=3","gravatar_id":"","url":"https://api.github.com/users/alexey-malov","html_url":"https://github.com/alexey-malov","followers_url":"https://api.github.com/users/alexey-malov/followers","following_url":"https://api.github.com/users/alexey-malov/following{/other_user}","gists_url":"https://api.github.com/users/alexey-malov/gists{/gist_id}","starred_url":"https://api.github.com/users/alexey-malov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexey-malov/subscriptions","organizations_url":"https://api.github.com/users/alexey-malov/orgs","repos_url":"https://api.github.com/users/alexey-malov/repos","events_url":"https://api.github.com/users/alexey-malov/events{/privacy}","received_events_url":"https://api.github.com/users/alexey-malov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-07T19:43:04Z","updated_at":"2015-02-07T19:46:41Z","closed_at":null,"body":"```\r\n    bool const operator == (const CStudent& other) const\r\n    {        \r\n        return ((CPerson)(*this) == (CPerson)(other)) && (m_course == other.m_course) && \r\n                m_university == other.m_university;\r\n    }\r\n```\r\nТут у тебя происходит т.н. \"срезка\", при которой создается временный объект (точнее, 2 объекта-копии this и other) типа CPerson. Чтобы срезка не происходила, ты должен приводить к типу CPerson const &.\r\nКроме того. у тебя тут используется c-style cast. Лучше использовать static_cast\r\n Если ты хочешь вызвать метод родительского класса, то используй следующую форму: записи:\r\nreturn CPerson::operator==(other) && ...\r\nOther приводить к типу CPerson не нужно, т.к. он может быть неявно приведен вверх по иерархии наследования\r\n\r\nА вообще у тебя и в таком виде будет метод реализован некорректно, т.к. не будет работать коммутативность в случае разных типов, а также при сравнении студентов по ссылкам типа CPerson. Например:\r\n```\r\nCPerson person(true, 16, 1.7 70, \"Ivanov Ivan\");\r\nCStudent student(true, 16, 1.7 70, \"Ivanov Ivan\", 3, someUniversity);\r\nassert(person == student); // true, хотя это вообще разные сущности\r\nassert(student == person); // а это вообще не скомпилируется.\r\n```\r\n\r\n```\r\nCPerson person(true, 16, 1.7 70, \"Ivanov Ivan\");\r\nCStudent student(true, 16, 1.7 70, \"Ivanov Ivan\", 3, someUniversity);\r\nCPerson & studentAsPerson = student;\r\nassert(person == studentAsPerson); // true, хотя это разные сущности\r\nassert(studentAsPerson) == person); // true, хотя это разные сущности\r\n```\r\n\r\n```\r\nCStudent student1(true, 16, 1.7 70, \"Ivanov Ivan\", 3, someUniversity);\r\nCStudent student2(true, 16, 1.7 70, \"Ivanov Ivan\", 4, someOtherUniversity);\r\nCPerson &  student1AsPerson = student1;\r\nCPerson &  student2AsPerson = student2;\r\nassert(student1AsPerson == student2AsPerson); // true, хотя это студенты разных вузов\r\nassert(student1 == student2); // false, корректно\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Andrey540/faststart_Egoshin_Andrey/issues/comments/73379688","html_url":"https://github.com/Andrey540/faststart_Egoshin_Andrey/issues/16#issuecomment-73379688","issue_url":"https://api.github.com/repos/Andrey540/faststart_Egoshin_Andrey/issues/16","id":73379688,"user":{"login":"alexey-malov","id":6040682,"avatar_url":"https://avatars.githubusercontent.com/u/6040682?v=3","gravatar_id":"","url":"https://api.github.com/users/alexey-malov","html_url":"https://github.com/alexey-malov","followers_url":"https://api.github.com/users/alexey-malov/followers","following_url":"https://api.github.com/users/alexey-malov/following{/other_user}","gists_url":"https://api.github.com/users/alexey-malov/gists{/gist_id}","starred_url":"https://api.github.com/users/alexey-malov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexey-malov/subscriptions","organizations_url":"https://api.github.com/users/alexey-malov/orgs","repos_url":"https://api.github.com/users/alexey-malov/repos","events_url":"https://api.github.com/users/alexey-malov/events{/privacy}","received_events_url":"https://api.github.com/users/alexey-malov/received_events","type":"User","site_admin":false},"created_at":"2015-02-07T19:46:41Z","updated_at":"2015-02-07T19:46:41Z","body":"```\r\nvoid CUniversity::ChangeStudent(unsigned index, const CStudent& student)\r\n{\r\n    if (index > m_students.size() || index == 0)\r\n    {\r\n        throw runtime_error(\"Incorrect student index\");\r\n    }\r\n    m_students[index - 1] = std::make_shared<CStudent>(student);\r\n    m_isModified = true;\r\n}\r\n```\r\nТут у тебя в массив помещается копия студента"}}