Why we exclude the last parameter ,and why it is written as (a+n) why not (a+n-1),
About parameters of sort function
there are two reasons :-
- definition of sort stl is
Sorts the elements in the range
[first,last)into ascending order.
and last means the last position where a new element could be added not the end position
2. for easy computation of size of array as arrays are indexed with 0 thus if we provide the address of (a+n) and a then we can simply compute n by subtracting once
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.