[英]C++ vector of array of strings?
I want to have a dynamic structure which I could iterate on, there will be unknown number of entries and known number of strings for each entry. 我想要一个可以迭代的动态结构,将有未知数量的条目,并且每个条目的字符串数也已知。 I thought that vector of array of strings could be the way, however I get error while compiling this: 我以为字符串数组的向量可能是这种方式,但是在编译时出现错误:
vector< array<string, 5> >
error: invalid use of incomplete type 'struct std::array<std::basic_string<char>, 5u>'
错误: invalid use of incomplete type 'struct std::array<std::basic_string<char>, 5u>'
What am I doing wrong? 我究竟做错了什么? and if this is kind of the way - how would I add/get values to/from this structure? 如果这是一种方式-我将如何向该结构中添加值/从中获取值?
Did you include all these three headers? 您是否包含所有这三个标头?
#include <vector>
#include <array>
#include <string>
This compiles just fine: 这样编译就可以了:
#include <vector>
#include <array>
#include <string>
int main(int argc, char const *argv[])
{
std::vector<std::array<std::string, 5> > myVec;
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.