初始化私有静态const向量<vector <string>&gt;类成员</vector <string>

时间:2015-02-18 03:41:08

标签: c++ vector

此处的关键字是多维的,string

我有两个不同的多维数组,它们都是static const vector<vector<T> >,但是一个是int向量,另一个是string向量。初始化int向量fooGroups时没有问题,但string向量barGroups让我适合。

我在这一点上找到的任何内容都没有解决所有这些事情,这种方式可以解决我的问题,因为即使vector<string> tGroups在我测试时也能正常工作,以确保它不是抛出它的类型关闭。

#include <vector>
#include <string>

class T {
    private:
        static const std::vector<std::string> tGroups;
        static const std::vector<std::vector<int> > fooGroups;
        static const std::vector<std::vector<std::string> > barGroups;
};

const std::vector<std::string> T::tGroups = {
    "blah","blah","blah","blah"
};

const std::vector<std::vector<int> > T::fooGroups = {
    //L0, L1, L2, ...
    {0,0,15},
    {0,0,6},
    {0,0,4}
};

const std::vector<std::vector<std::string> > T::barGroups = {
    {"blah","blah"},
    {"blah","blah","blah","blah"},
    {"blah","blah","blah"}
};

错误如下:

26|error: no matching function for call to 'std::vector<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >::vector(<brace-enclosed initializer list>)'

0 个答案:

没有答案
相关问题