 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can create dynamic 2D array in C++ using new operator. Before starting, you can note my information, you can connect with me by following these details. You can download my app Techimage that is available on Google Play. If you want to watch more programming related videos, you can search my name on YouTube. My channel will be available there. You can open it. Here you can subscribe my YouTube channel by clicking on this button. You can watch various programming related videos and playlists which are available here. Now coming on to the topic. Here I am going to implement a code which will demonstrate you how you can create dynamic 2D array in C++ using new and delete operators. So first I am including a header file IO stream. Then I am using a namespace std. It is a predefined namespace available in IO stream. It is used for scene and see out. Then I am using name of class array. First I am declaring a pointer to pointer and then two more variables R and C are for row and C for columns. Then in public section I am declaring first function set size, second function destroyer, third function is read and fourth function is print. Then I am terminating the class. After implementation of this class, I am going to define definitions for these four functions. So I am defining first function void is written type here then array is name of class then set size is name of function. Inside this function first I have to read rows and columns value. I am reading these values inside R and C variables using endl for line termination. Now first I am going to create memory blocks for rows using this statement. This will create array of pointers because I have used new int asterisk. So new will be creating dynamic memory of integer pointer type and r number of blocks will be created. Now I am using for loop. It will repeat r times and it will create memory for columns using new int C. So this way 2d array will be created in two steps. First I am creating number of rows and then each row will be created by repeating this loop. After creation of memory, I am implementing second function which is destroyer. It will deallocate the allocated memory by new operator. So here I am implementing loop which is repeating r times. First it will delete po5 array which is allocating memory for columns. Then after deletion of those columns I am deleting p which is pointing to array of pointers. So friends these are two functions which are allocating and deallocating dynamic memory for 2d array. Now I am implementing third function definition that is read. Inside this function I am declaring two variables i and j. Then first for loop for rows inside this second for loop is for columns and then scene statement for reading elements. So this is read function which will read all the elements of 2d array. Now I am implementing print function which will display elements on console. So I am copying these for loops and I have pasted here instead of scene I am using cout. And for new line I am using andel because I want to print the elements in matrix format. Here I am using space so that space will be printed between two elements. So friends this is the definition of print function. Now after these definitions I am implementing main method. Inside main method I am declaring an array object a1 then I am calling a1.set size then a message enter values. Then I am calling a1.read function then a message you have entered then a1.print and at last a1.destroy. And then return 0 because return type of main is integer. So I have called all the functions set size read print and destroy. So after implementation of this code I am going to execute this. You can see it is asking for number of rows and columns. So I am entering two as number of rows and three as number of columns. So I am going to enter six elements. You can see the output two rows and three columns are printed here in the matrix format. So friends I hope you have understood how we can create dynamic 2d array using new and delete operator. I have allocated and also deallocated memory for this 2d array. If you want to watch more programming related videos you can visit my channel on YouTube by following my name. You can also subscribe it. Here various videos and playlist are available on various programming language related. Thank you for watching this video.