Didn't understand the answer

*itr should return the value stored at the position pointed by itr. As itr==s.end(), it should return a garbage value, then why is it outputting 6?

hello @Swapnil-Ahlawat-2631017310330283

if s is (ordered set/map ) then
s.end() will always contains the number of element .

in ur case set is containing 6 elements thats why it is giving 6 as output.

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.