私は、このコンパイルエラーを取得:マップイテレータ:単項の無効な型引数「*」(「int型」を持っている)
error: invalid type argument of unary '
*
' (have 'int
')
_M_insert_unique_(end(), *__first);
私は(*cols_it).first
と(*cols_it).second
を使用してみましたし、私は考えることができる他のすべての順列ましたが、コンパイルすることはできません。私は何を書いていますか?
は、ここでは、コードの一部です:
#include <map>
#include <vector>
using std::map;
using std::vector;
void setZeroes(vector<vector<int> > &A) {
map<int,int> rows;
map<int,int> cols;
for (unsigned int x = 0; x < A[0].size(); x++) {
for (unsigned int y = 0; y < A.size(); y++) {
if (A[x][y] == 0) {
rows.insert(y,y); // error reported here
cols.insert(x,x);
}
}
}
map<int,int>::iterator rows_it = rows.begin();
map<int,int>::iterator cols_it = cols.begin();
while (rows_it != rows.end()) {
for (unsigned int i = 0; i < A[0].size(); i++) {
int val = rows_it->second;
A[val][i] = 0;
}
rows_it++;
}
while (cols_it != cols.end()) {
for (unsigned int i = 0; i < A.size(); i++) {
int val = cols_it->second;
A[i][val] = 0;
}
cols_it++;
}
}
ところで、多分あなたはかなりのstd ::フォームのストアのペアよりも設定を使用したい「X - > X」マップで? – bipll