此处的关键字是多维的,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>)'