jave.web
jave.web

Reputation: 15032

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>'

What am I doing wrong? and if this is kind of the way - how would I add/get values to/from this structure?

Upvotes: 0

Views: 1347

Answers (1)

user3647854
user3647854

Reputation:

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;
}

Upvotes: 3

Related Questions