How to work around a very large 2d array in C++ -


i need create 2d int array of size 800x800. doing creates stack overflow (ha ha).

i'm new c++, should vector of vectors? , encapsulate 2d array class?

specifically, array zbuffer in graphics program. need store z value every pixel on screen (hence large size of 800x800).

thanks!

you need 2.5 megs, using heap should fine. don't need vector unless need resize it. see c++ faq lite example of using "2d" heap array.

int *array = new int[800*800]; 

(don't forget delete[] when you're done.)


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -