How to insert a pair of elements as single elements in a set container?
My simple code is like this :
#include<iostream>
#include<set>
using namespace std;
void main() {
set<string,string> myset;
myset.insert(pair<string,string>("abc","def"));
cout<<myset.size()<<endl;
}
i.e. I want to take pairs as set elements. But this code generates error.
In map container also I'm facing difficulties to insert distinct pairs as
elements. But in case of ("abc","def") and ("abc","ghe"), for same key
value i.e. "abc", the second pair cannot be taken into the container even
though the pairs are distinct for the second element of the pairs .
How to change my code to get the job done ?
No comments:
Post a Comment