C++ 向量的初始化向量(外部向量和内部向量)

C++ 向量的初始化向量(外部向量和内部向量),c++,vector,C++,Vector,这里有很多类似的问题,但我并没有找到任何能特别回答我问题的答案 我有一个向量向量作为类的属性。另一个属性是bucket\u count。我想将向量的向量初始化为bucket\u count的大小,然后将其中的每个向量初始化为单个“” 目前,我有 class QueryProcessor { private: int bucket_count; // store all strings in one vector vector<vector<string

这里有很多类似的问题,但我并没有找到任何能特别回答我问题的答案

我有一个向量向量作为类的属性。另一个属性是
bucket\u count
。我想将向量的向量初始化为
bucket\u count
的大小,然后将其中的每个向量初始化为单个“”

目前,我有

class QueryProcessor {
private:    
    int bucket_count;
    // store all strings in one vector
    vector<vector<string> > hash_table(bucket_count);
我认为这可能是因为没有初始化向量,所以出现了上面的问题


编辑:忘了说明我想要一种在类定义中不使用for循环的方法,
向量哈希表(bucket\u count)
声明一个函数,该函数接受
桶计数
并返回
向量

在构造函数中初始化:

QueryProcessor:: QueryProcessor(int count)
    : bucket_count(count),
      hash_table(bucket_count, vector<string>(1))
{
}
QueryProcessor::QueryProcessor(int计数)
:桶计数(计数),
哈希表(桶计数,向量(1))
{
}

每个
向量需要多少个元素
?开始时,每个元素可以有零个元素(当程序运行时,我将
推回
)或
向量哈希表=向量(桶计数,向量(1))
QueryProcessor:: QueryProcessor(int count)
    : bucket_count(count),
      hash_table(bucket_count, vector<string>(1))
{
}