#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;
}
Why the output of this code is 0?
This code is meant to show that the insert function in the set returns a pair that contains set:iterator and the value bool. The insert function is used to add new elements to the set. We have just depicted that the return value of set is a pair of set:iterator pointing to the element and value of element we just inserted.
For more info about set::insert function. You can check http://www.cplusplus.com/reference/set/set/insert/
1 Like
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.