Category : vector

How can I access 2d vector using auto iterator? I write a code using auto iterator but it is not run just showing: – Compilation Error: Compilation Error prog.cpp: In member function std::vectorstd::vector<int > Solution::sortedMatrix(int, std::vectorstd::vector<int >): prog.cpp:18:31: error: no match for operator[] (operand types are std::vectorstd::vector<int > and __gnu_cxx::__normal_iteratorstd::vector<int*, std::vectorstd::vector<int > >) for(auto col ..

Read more

I am trying to get an input to a matrix by placing the whole thing as in a function outside of main (), as follows: void input_matrix(int row, int col){ std::vector<std::vector<int>> matrix; for (int m=0; m<row; m++){ for (int n=0; n<col; n++){ std::cin >> matrix[m][n]; } } return matrix; } somehow the compiler doesn’t like ..

Read more

I want to implement search by typing breeds name and display the row that I stored in txt how can I make that one? 799 Parrot male 5 1999 Owl male 1 void Inventory::findcat() { system("cls"); cout << "breeds;"; vector<Cat>::iterator iter = catVec.begin(); int i = 1; while (iter != catVec.end()) { cout << left ..

Read more