0

In code there are two map.One store pair and other store where Values is class with 5 variable with data type string,int,string,int,int.but during inserting in the second map i am getting error g++ error: no match for ‘operator<’ in ‘__x < __y’ when trying to insert in map. (Note Keys and Values in first map changes to Values,Key in second map)

How to solve it.

 class Values
    {
    private:
    std::string C_addr;
    int C_port;
    std::string S_addr;
    int S_port;
    int C_ID;

    public:
    Values(std::string,int,std::string,int,int);
    void printValues();
    };


    Values :: Values(std::string Caddr,int Cport,std::string Saddr,int Sport,int Cid)
    {
    C_addr=Caddr;
    C_port=Cport;
    S_addr=Swaddr;
    S_port=Sport;
    C_ID=Cid;
    }

    void Values::printValues()
    {
    cout << C_addr<<":" <<C_port<<":" << S_addr <<":" <<S_port << ":"<<C_ID  <<endl;
    }


    map<int, Values> items;
    map<Values,int> itemscopy;



    Values connection (inet_ntoa(Caddr.sin_addr),ntohs(Caddr.sin_port),inet_ntoa(Saddr.sin_addr),ntohs(Saddr.sin_port),CID);


    for(unsigned int key=0;key<=30000;    )
    {
    map<int,Values>::const_iterator itemsIterator=items.find(key);

    if(itemsIterator==items.end())
    {
    items.insert(pair<int, Values> (key, connection));
    {
    map<Values,int>::const_iterator itemsIterator1;
    if(itemsIterator1==itemscopy.end())
    itemscopy.insert(pair<Values,int> (connection, key));
    }
    break;
    }
    else
    {
    cout<<"already exist";
    key=key+1;
    }
    }
user3381955
  • 47
  • 1
  • 9

0 Answers0