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:\software\destination\Qt5.6.1\Tools\mingw492_32\i686-w64-mingw32\include\c++\bits\alloc_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>>即可

posted @ 2021-01-30 15:50  撑死算工伤吗  阅读(1449)  评论(0编辑  收藏  举报