In video “Allocating 2d Array Using Dynamic Memory Allocation In C++” Please look at 11:51 line-22 here the for loop is written to delete the secondary allocated array but secondary allocated array has 4 column where as the video show only deleting 3 column (for-loop-condition (i<3) )
Wrong for-loop condition
@vashish888 hey Ashish Code which written in the video is right. First understand this “delete[]” means we are deallocating whole array. and “delete” means we are deallocating one block.
e.g.
int bucket = new int;
delete bucket.
int *array = new int[5];
delete[] array.
If you understood this concept than see this Memory Allocation Diagram which clears your doubt.
Photo Link : https://drive.google.com/drive/folders/1qMBND6OOv-SkEgOs_L8XKmH6_-1ayS7U
@vashish888 hey Ashish, if your query is resolved. Please mark this doubt as resolved or if you have any query then tell me, I am happy to help you out.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.