I have this structure in c++:
struct Vertex_2 {
GLdouble position[3];
};
I am trying to access the array inside of it like this:
Vertex_2.position[0] = //something;
Vertex_2.position[1] = //something;
....
...
..
when I compile it I get this:
error: expected unqualified-id before ‘.’ token
why is that?
You have to create an instance of the
structbefore using the members thereof.Think of
Vertex_2as a description of what allVertex_2‘s should look like (but it is not, itself, aVertex_2). Then you have to actually create aVertex_2, by doingVertex_2 name;. In the example, we used the namevinstead ofname, but you can name the instance whatever you want. Then you can access the member variables of that instance through the name with a dot (.), like you tried to do before.