Syntax Error: Declaring a vector of known size vectors

Good afternoon,

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


EDIT:

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:

1
2
3
4
5
6
7
8
9
10
std::vector<std::vector<float> > vertices(1, std::vector<float>(3));

for (int v = 0; v<100; v++)
{
    vertices.push_back(std::vector<float>(3));
    vertices[v][0] = x; 
    vertices[v][1] = y;
    vertices[v][2] = z;
}
Last edited on
Topic archived. No new replies allowed.