C++出现error: 'class std::vector<int, std::allocator<std::basic_string<char> > >' has no member named 'deallocate'

代码如下:

class SpeechManager
{
public:
    vector<vector<int>> vec;    //保存第一轮、第二轮、决赛选手编号
    map<int, Speaker> m_Speaker;    //所有选手信息-编号+选手类
    vector<int> m_RandomV;  //抽签顺序存放容器
    int m_Index;    //当前轮数
    vector<int, vector<string>> m_Records;    //往届记录
}

编译出错:

D:softwaredestinationQt5.6.1Toolsmingw492_32i686-w64-mingw32includec++itsalloc_traits.h:383: error: 'class std::vector<int, std::allocator<std::basic_string<char> > >' has no member named 'deallocate'
       { __a.deallocate(__p, __n); }
         ^

分析解决:

分析error后的提示,对于vector容器来说,里面存放的只有一种类型的数据,而在C++的常见容器中,只有map/multimap支持键值对存放形式,所以将存放往届记录的类成员变量的类型设置为map<int, vector<string>>即可

原文地址:https://www.cnblogs.com/BASE64/p/14349284.html