C++ 如何使用带向量的哈希表创建构造函数(单独链接)

C++ 如何使用带向量的哈希表创建构造函数(单独链接),c++,vector,constructor,hashtable,C++,Vector,Constructor,Hashtable,我正在尝试创建一个用于单独链接的向量哈希表的构造函数。我一直收到一个错误,上面写着: 错误:“表”之前应为主表达式 #include <iostream> #include <vector> #include <list> #include <stdexcept> // Custom project includes #include "Hash.h" // Namespaces to include using std::

我正在尝试创建一个用于单独链接的向量哈希表的构造函数。我一直收到一个错误,上面写着:

错误:“表”之前应为主表达式

#include <iostream>
#include <vector>
#include <list>
#include <stdexcept>

// Custom project includes
#include "Hash.h"

// Namespaces to include
using std::vector;
using std::list;
using std::pair;

//
// Separate chaining based hash table - inherits from Hash
//
template<typename K, typename V>
class ChainingHash : public Hash<K,V> {
private:
    vector<list<V>> table;          // Vector of Linked lists

public:
    ChainingHash(int n = 11) {

        table = vector<list<K,V>> table(n);

    }
#包括
#包括
#包括
#包括
//自定义项目包括
#包括“Hash.h”
//要包括的名称空间
使用std::vector;
使用std::list;
使用std::pair;
//
//基于单独链接的哈希表-从哈希表继承
//
样板
类ChainingHash:公共哈希{
私人:
向量表;//链表的向量
公众:
ChainingHash(int n=11){
表=向量表(n);
}

这一行没有意义。您试图将赋值表达式与变量定义语句结合起来。不仅如此,您还有
list
,当存储表需要
list
时,这一行没有意义

table = vector<list<K,V>> table(n);  // <-- completely broken syntax
使用上述构造函数定义,
成员将使用
n
空列表初始化,这似乎就是您试图执行的操作

ChainingHash(int n = 11)
    : table(n)
{
}