Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#32 closed ожидается проверка (задача сдана)

Home assignment #1 matrices

Reported by: yusupov.samat Owned by: Vladimir Rutsky
Priority: проверка Milestone:
Component: HA#1 matrices Version:
Keywords: Cc: yusupov.samat

Description


Change History (9)

comment:1 Changed 8 years ago by Vladimir Rutsky

Type: ожидается проверкаожидаются исправления

Я не вижу вашей работы в Subversion, вы уверены, что закоммитили её куда нужно?

comment:2 Changed 8 years ago by yusupov.samat

Type: ожидаются исправленияожидается проверка

Извините, не заметил, что репозитории поменялись с прошлого года:
http://trac.compscicenter.ru/svn/cpp15/yusupov.samat

На что Александр ответил:
"Пока переносить не нужно —напишите в тикете о своей проблеме,
что закоммитили в старый репозиторий. "

comment:3 Changed 8 years ago by Vladimir Rutsky

Type: ожидается проверкаожидаются исправления

Самат, я вижу вашу работу в прошлогоднем репозитории, но она там не исправлена (последние изменения 25 октября 2015).

Напомню, что для того варианта мною были выписаны следующие замечания, и они не исправлены:

  1. Не используйте макроконстанты. Используйте enumeration для ADD и MULT.
  1. Ваше решение не компилируется: вы включаете matrices.h, а закоммичен у вас matrices.hpp.

Если переименовать matrices.hpp в matrices.h, то решение не

собирается со следующими ошибками в G++ 4.8 (часть из которых должна
решиться сборкой в компиляторе, поддерживающем C++14):

main.cpp: In function ‘void parse_args(int, char**, std::string*, short
int*)’:
main.cpp:17:23: error: ‘invalid_argument’ is not a member of ‘std’
                 throw std::invalid_argument(errorMsg);
                       ^
main.cpp: In function ‘int main(int, char**)’:
main.cpp:35:42: error: expected unqualified-id before ‘&’ token
     } catch (const std::invalid_argument &e) {
                                          ^
main.cpp:35:42: error: expected ‘)’ before ‘&’ token
main.cpp:35:42: error: expected ‘{’ before ‘&’ token
main.cpp:35:43: error: ‘e’ was not declared in this scope
     } catch (const std::invalid_argument &e) {
                                           ^
main.cpp:35:44: error: expected ‘;’ before ‘)’ token
     } catch (const std::invalid_argument &e) {
                                            ^
main.cpp:40:60: error: use of deleted function
‘std::basic_ifstream<char>::basic_ifstream(const
std::basic_ifstream<char>&)’
     std::ifstream f = std::ifstream(std::ifstream(files[0]));
                                                            ^
In file included from main.cpp:2:0:
/usr/include/c++/4.8/fstream:427:11: note:
‘std::basic_ifstream<char>::basic_ifstream(const
std::basic_ifstream<char>&)’ is implicitly deleted because the default
definition would be ill-formed:
     class basic_ifstream : public basic_istream<_CharT, _Traits>
           ^
/usr/include/c++/4.8/fstream:427:11: error: use of deleted function
‘std::basic_istream<char>::basic_istream(const std::basic_istream<char>&)’
In file included from /usr/include/c++/4.8/iostream:40:0,
                 from main.cpp:1:
/usr/include/c++/4.8/istream:58:11: note:
‘std::basic_istream<char>::basic_istream(const std::basic_istream<char>&)’
is implicitly deleted because the default definition would be ill-formed:
     class basic_istream : virtual public basic_ios<_CharT, _Traits>
           ^
/usr/include/c++/4.8/istream:58:11: error: use of deleted function
‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’
In file included from /usr/include/c++/4.8/ios:44:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from main.cpp:1:
/usr/include/c++/4.8/bits/basic_ios.h:66:11: note:
‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’ is
implicitly deleted because the default definition would be ill-formed:
     class basic_ios : public ios_base
           ^
In file included from /usr/include/c++/4.8/ios:42:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from main.cpp:1:
/usr/include/c++/4.8/bits/ios_base.h:786:5: error:
‘std::ios_base::ios_base(const std::ios_base&)’ is private
     ios_base(const ios_base&);
     ^
In file included from /usr/include/c++/4.8/ios:44:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from main.cpp:1:
/usr/include/c++/4.8/bits/basic_ios.h:66:11: error: within this context
     class basic_ios : public ios_base
           ^
In file included from main.cpp:2:0:
/usr/include/c++/4.8/fstream:427:11: error: use of deleted function
‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’
     class basic_ifstream : public basic_istream<_CharT, _Traits>
           ^
/usr/include/c++/4.8/fstream:427:11: error: use of deleted function
‘std::basic_filebuf<char>::basic_filebuf(const std::basic_filebuf<char>&)’
/usr/include/c++/4.8/fstream:72:11: note:
‘std::basic_filebuf<char>::basic_filebuf(const std::basic_filebuf<char>&)’
is implicitly deleted because the default definition would be ill-formed:
     class basic_filebuf : public basic_streambuf<_CharT, _Traits>
           ^
In file included from /usr/include/c++/4.8/ios:43:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from main.cpp:1:
/usr/include/c++/4.8/streambuf:802:7: error: ‘std::basic_streambuf<_CharT,
_Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>&)
[with _CharT = char; _Traits = std::char_traits<char>]’ is private
       basic_streambuf(const basic_streambuf& __sb)
       ^
In file included from main.cpp:2:0:
/usr/include/c++/4.8/fstream:72:11: error: within this context
     class basic_filebuf : public basic_streambuf<_CharT, _Traits>
           ^
main.cpp:40:60: error: use of deleted function
‘std::basic_ifstream<char>::basic_ifstream(const
std::basic_ifstream<char>&)’
     std::ifstream f = std::ifstream(std::ifstream(files[0]));
                                                            ^
main.cpp:43:54: error: use of deleted function
‘std::basic_ifstream<char>::basic_ifstream(const
std::basic_ifstream<char>&)’
         f = std::ifstream(std::ifstream(files[i + 1]));
                                                      ^
main.cpp:43:11: error: use of deleted function ‘std::basic_ifstream<char>&
std::basic_ifstream<char>::operator=(const std::basic_ifstream<char>&)’
         f = std::ifstream(std::ifstream(files[i + 1]));
           ^
In file included from main.cpp:2:0:
/usr/include/c++/4.8/fstream:427:11: note: ‘std::basic_ifstream<char>&
std::basic_ifstream<char>::operator=(const std::basic_ifstream<char>&)’ is
implicitly deleted because the default definition would be ill-formed:
     class basic_ifstream : public basic_istream<_CharT, _Traits>
           ^
/usr/include/c++/4.8/fstream:427:11: error: use of deleted function
‘std::basic_istream<char>& std::basic_istream<char>::operator=(const
std::basic_istream<char>&)’
In file included from /usr/include/c++/4.8/iostream:40:0,
                 from main.cpp:1:
/usr/include/c++/4.8/istream:58:11: note: ‘std::basic_istream<char>&
std::basic_istream<char>::operator=(const std::basic_istream<char>&)’ is
implicitly deleted because the default definition would be ill-formed:
     class basic_istream : virtual public basic_ios<_CharT, _Traits>
           ^
/usr/include/c++/4.8/istream:58:11: error: use of deleted function
‘std::basic_ios<char>& std::basic_ios<char>::operator=(const
std::basic_ios<char>&)’
In file included from /usr/include/c++/4.8/ios:44:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from main.cpp:1:
/usr/include/c++/4.8/bits/basic_ios.h:66:11: note: ‘std::basic_ios<char>&
std::basic_ios<char>::operator=(const std::basic_ios<char>&)’ is
implicitly deleted because the default definition would be ill-formed:
     class basic_ios : public ios_base
           ^
In file included from /usr/include/c++/4.8/ios:42:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from main.cpp:1:
/usr/include/c++/4.8/bits/ios_base.h:789:5: error: ‘std::ios_base&
std::ios_base::operator=(const std::ios_base&)’ is private
     operator=(const ios_base&);
     ^
In file included from /usr/include/c++/4.8/ios:44:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from main.cpp:1:
/usr/include/c++/4.8/bits/basic_ios.h:66:11: error: within this context
     class basic_ios : public ios_base
           ^
In file included from main.cpp:2:0:
/usr/include/c++/4.8/fstream:427:11: error: use of deleted function
‘std::basic_filebuf<char>& std::basic_filebuf<char>::operator=(const
std::basic_filebuf<char>&)’
     class basic_ifstream : public basic_istream<_CharT, _Traits>
           ^
/usr/include/c++/4.8/fstream:72:11: note: ‘std::basic_filebuf<char>&
std::basic_filebuf<char>::operator=(const std::basic_filebuf<char>&)’ is
implicitly deleted because the default definition would be ill-formed:
     class basic_filebuf : public basic_streambuf<_CharT, _Traits>
           ^
In file included from /usr/include/c++/4.8/ios:43:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from main.cpp:1:
/usr/include/c++/4.8/streambuf:810:7: error: ‘std::basic_streambuf<_CharT,
_Traits>& std::basic_streambuf<_CharT, _Traits>::operator=(const
std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char; _Traits =
std::char_traits<char>]’ is private
       operator=(const basic_streambuf&) { return *this; };
       ^
In file included from main.cpp:2:0:
/usr/include/c++/4.8/fstream:72:11: error: within this context
     class basic_filebuf : public basic_streambuf<_CharT, _Traits>
           ^
main.cpp:52:46: error: expected unqualified-id before ‘&’ token
         } catch (const std::invalid_argument &e) {
                                              ^
main.cpp:52:46: error: expected ‘)’ before ‘&’ token
main.cpp:52:46: error: expected ‘{’ before ‘&’ token
main.cpp:52:48: error: expected ‘;’ before ‘)’ token
         } catch (const std::invalid_argument &e) {
                                                ^
In file included from matrices.cpp:1:0:
matrices.h: In constructor ‘Matrix::Matrix(size_t, size_t)’:
matrices.h:36:12: warning: ‘Matrix::rows_’ will be initialized after
[-Wreorder]
     size_t rows_;
            ^
matrices.h:35:12: warning:   ‘size_t Matrix::cols_’ [-Wreorder]
     size_t cols_;
            ^
matrices.cpp:3:1: warning:   when initialized here [-Wreorder]
 Matrix::Matrix(size_t rows, size_t cols) : rows_(rows), cols_(cols) {
 ^
In file included from matrices.cpp:1:0:
matrices.h: In copy constructor ‘Matrix::Matrix(const Matrix&)’:
matrices.h:36:12: warning: ‘Matrix::rows_’ will be initialized after
[-Wreorder]
     size_t rows_;
            ^
matrices.h:35:12: warning:   ‘size_t Matrix::cols_’ [-Wreorder]
     size_t cols_;
            ^
matrices.cpp:18:1: warning:   when initialized here [-Wreorder]
 Matrix::Matrix(Matrix const &m) : rows_(m.rows()), cols_(m.cols()) {
 ^
matrices.cpp: In member function ‘Matrix Matrix::operator+(const Matrix&)
const’:
matrices.cpp:87:15: error: ‘invalid_argument’ is not a member of ‘std’
         throw std::invalid_argument("Can't add different columns and rows
number.");
               ^
matrices.cpp: In member function ‘Matrix Matrix::operator*(const Matrix&)
const’:
matrices.cpp:102:15: error: ‘invalid_argument’ is not a member of ‘std’
         throw std::invalid_argument("Can't multiply different columns and
rows number.");
               ^

  1. Это очень странная конструкция:
    std::ifstream f = std::ifstream(std::ifstream(files[0]));

достаточно сделать так:

    std::ifstream f(files[0]);

и я бы рекомендовал создавать по новому std::ifstream на каждый

читаемый файл.

  1. В случае возникновения ошибочных ситуаций (например, сложение матриц разного размера) вы завершаете программу не освободив выделенную память, что является утечкой памяти.

Вы уверены, что вам удалось успешно закоммитить ваше решение?
Возможно, вы закоммитили его в репозиторий другого курса (например, Java)?

comment:4 Changed 8 years ago by yusupov.samat

Добрый вечер, не понимаю почему так произошло возможно я и вправду не закомитил исправленную версию. Теперь в старое репо вообще не комитит (.

$yusupov.samat:  svn ci -m "test"
svn: E175013: Commit failed (details follow):
svn: E175013: Unable to connect to a repository at URL 'http://trac.compscicenter.ru/svn/cpp15/yusupov.samat/ha1'
svn: E175013: Access to '/svn/cpp15/yusupov.samat/ha1' forbidden

Запушил в репо этого года исправленное решение.

$yusupov.samat:  svn info
Path: .
Working Copy Root Path: /Users/Samat/Dev/CSC2015/c++/cpp16/yusupov.samat
URL: http://trac.compscicenter.ru/svn/cpp16/yusupov.samat
Relative URL: ^/yusupov.samat
Repository Root: http://trac.compscicenter.ru/svn/cpp16
Repository UUID: 26cb368e-3077-45ac-bba9-b61df8093f06
Revision: 206
Node Kind: directory
Schedule: normal
Last Changed Author: smal
Last Changed Rev: 153
Last Changed Date: 2016-10-21 21:03:35 +0300 (пт, 21 окт 2016)

comment:5 Changed 8 years ago by yusupov.samat

Cc: yusupov.samat added
Type: ожидаются исправленияожидается проверка

comment:6 Changed 7 years ago by Vladimir Rutsky

Milestone: ha1-milestone2ha1-deadline
Type: ожидается проверкаожидаются исправления

Замечания:

  1. Вы не обрабатываете ситуацию, когда не удалось открыть файл с матрицей. Например, запуск ./matrices xxx.txt приводит к падению программы.

comment:7 Changed 7 years ago by yusupov.samat

Type: ожидаются исправленияожидается проверка

Добрый вечер, исправил этот момент.

comment:8 Changed 7 years ago by Vladimir Rutsky

Resolution: задача сдана
Status: newclosed

Решение зачтено.

comment:9 Changed 7 years ago by Vladimir Rutsky

Milestone: ha1-deadline

Milestone ha1-deadline deleted

Note: See TracTickets for help on using tickets.