 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can swap values of two 1D arrays using call by reference in C++. Before starting, you can subscribe my YouTube channel by clicking on the link which is available at bottom right corner of this video. You can download my app tag immense that is available on Google Play. You can connect with me by following these details which are available in front of you. Now you can see a code which is implemented in front of you. First statement is comment which is showing swap values of two arrays using call by reference in C++. Then I have included header file IO string. Then I have used a namespace std which is defined in IO string. The same space I have used for seen and see out. Then class array is defined. It is containing an array in teaser type array which which is of five size. Then public access specify. So this array is private and after public section read print and swap these functions are declared. So these functions are in public section. So we can access these functions inside main function. So read function print function and swap three functions are declared here. Swap is receiving one argument, but read and print are not receiving any argument. After termination of class, first I have defined read function. So inside read function, you can see return type, then name of class, then scope resolution operator, then read is the name of function inside its definition. Variable i is declared. Then a loop is repeating five times from zero to four. And with the help of scene, I am reading values of array. After implementation of read function, print function is defined. It is similar to read, but it is using see out instead of see in. So it will be displaying elements which are available inside array and and is used to terminate the line. So each element will be displayed on new lines. The next function swap is defined here. Inside swap, one argument is received. That is X. X is formal argument here, which will receive the value of explicit argument that will be passed from main function. Then two variables i and t are declared. With the help of this for loop, I am going to swap values of two arrays. So this a of i is representing implicit argument and this X dot a of i is implement is representing explicit argument. So first study this main function here, two areas are declared a one and a two. Then see out will display enter first array message on console. Then a one dot read function is called. This will read first array similar to first array. Second array will be read using a two dot read. Then this statement is important here. A one dot swap a two statement is written. A one is implicit argument and a two is explicit argument. So this a two will be passed inside this X and X will be representing a two here. So when we implement call by reference by using this ampersand sign in formal argument, memory of explicit argument here a two memory of a two will be shared by this X. So whatever change we do in X formal argument that will be automatically applicable for a two because both are sharing same memory location and a one is passed implicitly so we can access it here directly. So this ai and this ai is representing implicit argument that is a one and this X dot a of i and this X dot a of i is representing this X which is sharing the memory of a two. So in short, we can say that a one and a two values are swapped using these three statements after completion of swapping using a one dot print and a two dot print. All the elements of arrays will be displayed on console. So after this explanation, I am executing this code. It is asking for first array elements. So I am entering one in first array and I am entering two in second array. You can see the result values of first arrays are now two and values of second array are now one. So with the help of this example, I have changed the values of sorry, I have swapped values of two and the arrays and I have followed the method called by reference in C++. I hope you have understood this concept well. If you want to watch more programming related videos, you can subscribe my YouTube channel that is Sajagukta underscore tech school. Thank you for watching this video.