제 질문은 this one과 거의 동일하지만 해결책이 제 오류를 해결하지 못했습니다. main.h
에서표준 : : 문자열을 키로 사용하여 std :: map을 반복 할 수 없습니다.
내가 가진 :
#include <map>
#include <string>
std::map<std::string, int64_t> receive_times;
그리고 main.cpp
에 :
std::map<std::string, int64_t>::const_iterator iter;
std::map<std::string, int64_t>::const_iterator eiter = receive_times.end();
for (iter = receive_times.begin(); iter < eiter; ++iter)
printf("%s: %ld\n", iter->first.c_str(), iter->second);
을하지만, 내가 노력하고 내가 다음과 같은 오류 얻을 컴파일 할 때 :
error: invalid operands to binary expression ('std::map<std::string, int64_t>::const_iterator' (aka '_Rb_tree_const_iterator<value_type>') and 'std::map<std::string, int64_t>::const_iterator'
(aka '_Rb_tree_const_iterator<value_type>'))
for (iter = receive_times.begin(); iter < eiter; ++iter)
~~~~^~~~~~
솔루션의를 상단에 링크 된 질문은 누락 되었기 때문입니다. #include <string>
,하지만 분명히 포함되어 있습니다. 어떤 힌트?
헤더 파일에 변수를 정의하면 안됩니다 ... –