-2

知道为什么这会产生编译错误吗?

std::unordered_map<int,int> mymap;
std::for_each(mymap.begin, mymap.end(), [](std::unordered_map<int, int>::value_type mapval) {
    std::cout << mapval.first << ",";
});

error: conversion from â<unresolved overloaded function type>â to non-scalar type âstd::_Rb_tree_iterator<std::pair<const int, int> >â requested
4

1 回答 1

4
mymap.begin()

您缺少(),begin是成员函数,而不是数据成员。

于 2012-04-12T20:49:43.147 回答