Syntax Error: Declaring a vector of known size vectors
I'm trying to declare scalable vectors of known size vectors. But everything I tried and everywhere I looked I could not find a description of how to do this.
The idea is to create a vector of vectors that holds some vertex coordinates (x, y, z)
I want to be able to expand the outer vector, but the inner vectors to stay the same size,
I tried declaring it as shown on this post http://www.daniweb.com/software-development/cpp/threads/145735/declare-2d-vector#
std::vector< std::vector<float> > vertices(1,std::vector<float>(3));
but this gives me (error C2143: syntax error : missing ')' before ';')
The reason for the error was because I was attempting to set the vector size in the Header not the body of a class. Once I moved everything to the body it worked perfectly.
I will mark the topic as solved in case someone else find this issue, or please feel free to delete it..
For Anyone's reference:
std::vector<std::vector<float> > vertices(1, std::vector<float>(3));
for (int v = 0; v<100; v++)
vertices[v] = x;
vertices[v] = y;
vertices[v] = z;
Last edited on
Topic archived. No new replies allowed.