Can you please explain the output? Why is it 0 and not 1?
Output in Ques 13
#include <bits/stdc++.h> using namespace std; int main() { sets; pair<set::iterator, bool> ret; s.insert(1); s.insert(5); s.insert(10); s.insert(3); ret = s.insert(10); cout<<ret.second<<endl; return 0; }
it’s messed up here. How can I send a screenshot?
From what i have gathered from the text, i think you want to ask about insert() function in the set.
set::insert() return a pair, with its member pair::first set to an iterator pointing to either the newly inserted element or to the equivalent element already in the set. The pair::second element in the pair is set to true if a new element was inserted or false if an equivalent element already existed.
I hope, I have cleared your doubt.
yes. I get it now. thank you