i know how to create a stack of vectors or int ,etc. But i dont know how to create a stack of a multidimentional arrays t[n][n] . Whats the way to implement it?
this is my actual implementation which its not working.
char map[20][20];
stack<map> soluciones;
Edit:
I think due my english most of you didnt undestand my question. Imagine i got some kind of a Game map. I am saving each multidimentional array on the stack. Thats my objective saving the map on a stack
Edit 2: im using Visual Studio 2010 Windows form application
In your code example, you use
map(the name of your variable) in place of where a type name must stand (instack<map>template instantiation). However, it won’t work, not even if you use the proper type name (in this case you’d have to use typedef, e.g.typedef char TwoDimCharArray[20][20]and then trystd::stack<TwoDimCharArray>:There is still the problem that arrays don’t have a default constructor (which
std::stackexpects); therefore,std::stackcannot be made to directly contain arrays; you’d have to wrap the array inside a class or struct (which can have a default constructor), e.g.:Or use
Boost.Arrayor C++11std::arraystuff! If these are available, they are definitely the better and easier choice!