나는 아주 간단한 문제가 있습니다. 참조로지도를 받아들이고지도의 키를 반복하는 함수를 만들려고합니다.함수에 대한 참조로 C++ 맵을 전달하려고하는데 코드를 반복 할 수 없지만 코드를 컴파일 할 수 없습니다.
#include <map>
#include <string>
#include <sys/types.h>
using namespace std;
void update_fold_score_map(string subfold,
int32_t index,
int32_t subfold_score,
map<string, int32_t> &fold_scores){
for(map<string, int32_t>::iterator i = fold_scores.begin();
i != fold_scores.end();
i ++){
string current_substring;
string fold;
fold = (*i);
current_substring = fold.substr(index, subfold.size());
if (current_substring == subfold){
if (fold_scores[fold] < subfold_score){
fold_scores[fold] = subfold_score;
}
return;
}
}
}
int main(){
return 0;
}
하지만 "fold = (* i);"줄에 오류가 있습니다. 어느 상태 :
compilemap.cpp:16:15: error: no match for ‘operator=’ in ‘fold = i.std::_Rb_tree_iterator<_Tp>::operator* [with _Tp = std::pair<const std::basic_string<char>, int>, std::_Rb_tree_iterator<_Tp>::reference = std::pair<const std::basic_string<char>, int>&]()’
의 다음을 시도/cpp/유틸리티/쌍). –