0

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?

2
  • 1
    Include all the headers you need to include. And make sure you have C++11. Commented Oct 23, 2014 at 18:35
  • 1
    compile with -std=c++11 Commented Oct 23, 2014 at 18:41

1 Answer 1

3

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;
}
Sign up to request clarification or add additional context in comments.

2 Comments

And the second part of the question - how do I add items to this vector (dynamicly)?
Using emplace_back: "myVec.emplace_back();" or push_back: "myVec.push_back(std::array<std::string, 5>());"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.