【问题标题】:C++ Multimap No Matching Member Function InsertC ++ Multimap没有匹配的成员函数插入
【发布时间】:2015-06-09 10:24:50
【问题描述】:
#include <map>
.
.
.
multimap<double, pair<int,int>> weightList;

for(int row = 0; row < matrixSize; row++ ){
    for(int column = 0; column < matrixSize; column++){
        double weight = matrix[row][column];

        weightList.insert(weight,make_pair(row, column));
    }
}

所以我收到一条错误消息,提示“没有匹配的成员函数来调用插入”。我不知道如何插入多张地图。如果您知道我还能如何插入到多地图中,我将不胜感激。

【问题讨论】:

  • 你试过std::make_pair吗? multimap.insert 也需要对类型,所以你会做类似 insert(std::pair >)
  • 不应该看起来像:weightList.insert(make_pair(weight,make_pair(row, column)));
  • 成功了,你们太棒了,谢谢!

标签: c++ data-structures associative-array multimap


【解决方案1】:

按照 cmets 的建议尝试使用

 insert(std::make_pair(weight, std::make_pair(a,b)));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-26
    • 2020-09-11
    • 2012-12-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多