how can we assign a set to a pair
Did not understand the particular question
question no 13 is my doubt
stl set iterator returned by insert
What will be the output of following C++ code?
#include <bits/stdc++.h>
using namespace std;
int main()
{
set<int>s;
pair<set<int>::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;
}
Choices
- 0
- Compilation Error
- Runtime Error
- 1
I did not understand your doubt.
Why can we not? pair is a template datatype and it can accept any kind of data structure. Just like you can make a vector of vectors, a set of pairs, a queue of class objects, etc
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.