 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can add all the elements which are available in dynamic 1d array in C++. Before starting, you can note my information, you can connect with me by following these details, you can download my app Takimas that is available on Google Play, you can subscribe my YouTube channel, you can search my name on YouTube, my channel will be available, you can open my channel by clicking on the link, you can see various playlists are available and you can subscribe my channel by clicking on this red button. Various programming related playlists and videos are available in my channel. Now coming on to the topic, you can see I have implemented a code for you which will demonstrate you how you can add all the elements of dynamic 1d array in C++. I have included a header file iostream, then I have used a namespace std, it is a predefined namespace available in iostream header file. Then class name is vector, whenever we create dynamic arrays that array is known as vector, that's why I have used name of class vector. Then two variables, one is pointer and one is size, pointer is named p and size variable is declared here. Then in public section five functions are declared, first is set size which will allocate dynamic memory, destroy, deallocates dynamic memory, read will read all the elements of dynamic 1d array, print will display all the elements of dynamic 1d array and some function will display addition of all the elements which are available in dynamic 1d array. Then I have terminated the class, after termination you can see first function is defined, here void is return type, vector is name of class, then scope resolution operator and then set size is the name of function. These functions are defined outside, so these all functions are known as outside member functions and you will be seeing that all functions are defined using scope resolution operator. Then see out will display enter size message on console, then size will be received by this size variable, then this statement is allocating dynamic memory, here new operator is used, new will be allocating dynamic memory of integer type and size will be available by this size variable and the beginning address will be stored inside p, now using p you can access all the locations of array, after this set size another function is defined that is destroy, in this function only one statement is available that is delete p, so delete will deallocates the dynamic memory allocated by new, then read function it is simple, void is return type, vector name of class then scope resolution then read function name, then i variable is declared, this loop is repeating size times and using c in values inside p of i will be stored, similar to read print function is defined, it is implementing a for loop starting from zero and condition is i less than size, it will display all the elements using c out on console, after print function some function is implemented, here two variables i and s are declared, then loop is repeating from zero to size, all the elements which are stored inside p will be added into s, after completion of this loop c out statement will display some on console by using this variable s, then after completion of some definition main function is implemented, here object v is declared, first it is calling set size function which will allocate dynamic memory, then values will be received by this v.read function call, then all the elements which you have entered will be displayed using v.print function call, then addition or sum will be displayed using v.sum function call, after completion of all these processes v.destroy function will be called, so destroy function will be deallocating all the memory which is allocated by the new operator, then return zero because return type of main is integer that's why return zero statement is written here, so this is the complete explanation of this code, now i am going to execute this code, you can see it is asking for the size i am entering five and i am entering five times one, you can see the output, you have entered one one one one one, it is displaying five times and sum equals to five is displayed, so friends this program has added all the elements which are available inside 1d array, it is adding only one 1d array, you can also add values of two 1d arrays and those results will be stored inside third 1d array, this concept i will be demonstrating in my another video, i hope you have understood the concept well, if you want to watch more programming related videos you can subscribe my youtube channel, you can search my channel on youtube by my name where various programming related videos and playlists are available, so keep following my youtube channel subscribe it, thank you for watching this video