Timeline for How do I declare a 2d array in C++ using new?
Current License: CC BY-SA 2.5
3 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 2, 2009 at 14:48 | comment | added | Tadeusz Kopec for Ukraine | The best thing is to wrap this code in a class - you can perform a clean-up in destructor and you can implements methods get(x, y) and set(x,y, val) instead of forcing user to do multiplication by himself. Implementing operator[] is more tricky, but I believe it's possible. | |
Jun 1, 2009 at 21:34 | comment | added | Dietrich Epp | This is a good way to do it. You can also do vector<int> with size sizeX*sizeY for some nice extra safety. | |
Jun 1, 2009 at 21:13 | history | answered | Isvara | CC BY-SA 2.5 |