Working of given function

hello @officialharshit1996
in the above code , we are just overloading [] operator

tell me , how it is working like we are returning int but return type is int&, how given statement is workingv[2]=2

i.e when we are doing v[2]=6 then refrence of 3rd element of vector is returned and 6 is assigned to it as value.

we are returrning the reference (int&) because because we want to make changes in original array only

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.