We need a two-dimensional dynamic vector that can be removed at any time.
Closed due to the fact that the essence of the question is incomprehensible by the participants of Suvitruf ♦ , freim , αλεχολυτ , 0xdb , aleksandr barakin on Feb 17 at 8:29 am .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
1 answer
vector<vector<int>> will suit you? Two-dimensional, dynamic, is removed when leaving the field of visibility ...
If not, formulate the question more accurately.
Yes, I answered the question about a two-dimensional array, because I think that you hardly need a two-dimensional vector in the original geometric sense :), which is just a pair of coordinates (x,y) and is completely realized as a structure or simply pair<,> ...
Update
Well, if you so want to "improved C" ...
int ** a = new int*[N]; for(int i = 0; i < N; ++i) a[i] = new int[M]; ..... for(int i = 0; i < N; ++i) delete[] a[i]; delete[] a; - Delete at any time. Probably using the delete operation, and creating with the help of new - zhukov February
- Yes, a two-dimensional array - zhukov
- @zhukov A two-dimensional array is called a matrix; a vector is a one-dimensional array. - Konstantin_SH
std::vectorstores three pointers or something similar, and the data itself is always on the heap. - HolyBlackCat