Vector of dynamic dimension

How do we create vectors of dynamic dimension like 2-dimensional vector, 3-dimensional, 4 dimensional...and so on where the dimension will only be determined at run time?
You could make a vector of vectors, if you wanted.
@Zhuge that's not what the OP asked.

@OP you can use inheritance and a nested structure, it's pretty complex. Why do you need it?
I'd need it to store chess generated moves....
I was thinking of that, nested structure but how do we implement it? Without using vector< vector<> > to implement a 2-D vector, how will it be implemented with nesting?

Last edited on
Why can't you use multiple 2D matrices to store moves? As in:

typedef int ChessBoard[8][8];

std::vector<ChessBoard> vcb; // or maybe more appropriately
std::list<ChessBoard> lcb;

this is usually done with trees. See the boost property tree:
@coder - that is exactly what I need and am trying to do. I have been trying to write my own tree code and I need to be able to create vectors of dynamic dimension.
@Catfish - 2-D works but is less efficient and would be difficult to evaluate positions as depth increases. It would be hard to track positions 20 moves deeper after a certain position. I had created my own 2-D model but it is slow. It would have to search among those lists which is no longer part of the branch. If a tree can be created, it would be more efficient.
Last edited on
But I think what I need is not really a tree generator but more of a mesh as some chess positions may arise from different move paths...
Topic archived. No new replies allowed.