Accessing class member in 2d array

I have a vector declared as
std::vector<std::vector<std :: vector <chunk> > > chunks;
This works, and for the sake of initialising works fine. I can fill it out with no problems. However, within chunk I've defined x and y.
I try to access it using
amap->chunks[xlocation][ylocation].x
I get a compiler error, "Class std::vector<chunk> has no member named x". However I can still use normal vector methods. How would I go about access the class members? Am I doing this entirely wrong??
Last edited on
It is a 3d construct; provide all three dimensions. chunks[xlocation][ylocation][zlocation].x
You've shown a 3d vector but have only used two indices to access it. Either make it a 2d vector:
vector<vector<chunk>> chunks;
or use three indices
chunks[x][y][z].x
If you described what the data structure is supposed to represent and how you are using it, we could give you some advice on which is best.
Now I feel stupid that makes alot of sense, thanks heaps.
Topic archived. No new replies allowed.