vendredi 14 juillet 2017

How to access elements of set

The snippet of my code is :

set<multimap<int,int> > myset[days+2];
set<multimap<int,int> >::iterator it,itf;
int d,t,s,t_days;
    int n,temp;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>d>>t>>s;
        myset[d].insert(t,s);
    }
    for(i=1;i<=days;i++)
    {
        it=myset[i].begin();
        t_days=it->first;
        temp=it->second;
        cout<<t_days<<" "<<temp<<endl;
    }

It is showing error:

new.cpp   In function 'int main()': [Error] 'const class
std::multimap<int, int>' has no member named 'first' [Error] 'const
class std::multimap<int, int>' has no member named 'second'

I have also tried it.first but still it is showing same error.

Aucun commentaire:

Enregistrer un commentaire