调用push_back没有匹配函数

No matching function for call to push_back

本文关键字:函数 push back 调用      更新时间:2023-10-16

我想在控制台中打印一个二叉树,这是我写的代码,但我无法弄清楚这个错误。谁能帮我?错误是调用push_back没有匹配函数。

void getVerticalOrder(Node* root, int hd,std::map<int,std::vector<int> > &m)
    {
        // Base case
        if (node == NULL)
            return;
        // Store current node in map 'm'
        m[hd].push_back(root->payload); //Error in this line
        // Store nodes in left subtree
        getVerticalOrder(root->left, hd-1, m);
        // Store nodes in right subtree
        getVerticalOrder(root->right, hd+1, m);
    }

> 由于payload是字符串,因此您需要:

std::map<int,std::vector<std::string> >
//                         ~~~ vector of std::string