People help please!
There is a two-dimensional vector described in class. Cited only 2 methods of all, the extra did not write. Saving the matrix to the file works, but I tried to do the same way to load the matrix from the file into the program - it does not work! In the file, the matrix is of unknown size, but always rectangular.
typedef vector<vector<int>>::iterator matrix_iterator; class Matrix { public: vector<vector<int>>v; Matrix(); void SaveMatrix(int err); void LoadMatrix(); }; // если err=0 матрица не записывается, // err используется, чтоб не было бесконечной рекурсии void Matrix::SaveMatrix(int err) { if (!FileExists(FNAME_MATRIX) || err != 0) { ofstream ofst(FNAME_MATRIX); for (matrix_iterator it = v.begin(); it != v.end(); ++it) { copy(it->begin(), it->end(), ostream_iterator <int>(ofst, " ")); ofst <<endl; } cout <<"Матрица сохранена\n"; } else { char ch; cout << "Вы уверены, что хотите перезаписать матрицу? + или -\n"; cin>>ch; if (ch == '+') SaveMatrix(1); else cout <<"Матрица не сохранена\n"; } } void Matrix::LoadMatrix() { ifstream ifst(FNAME_MATRIX); while (!ifst.eof()) { int temp; ifst>>temp; matrix_iterator iterlvl2; vector<int>::iterator iterlvl1; for (iterlvl2 = v.begin(); iterlvl2 != v.end(); iterlvl2++) { iterlvl1 = (*iterlvl2).begin(); (*iterlvl2).push_back(temp); } } }