473,657 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error: no match for ‘operator<’ in ‘__x < __y’

1 New Member
In code there are two map.One store pair<key,Values > and other store <Values,key> where Values is class with 5 variable with data type string,int,stri ng,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.
Expand|Select|Wrap|Line Numbers
  1.      class Values
  2.      {
  3.      private:
  4.         std::string C_addr;
  5.         int C_port;
  6.         std::string S_addr;
  7.         int S_port;
  8.         int C_ID;
  9.  
  10.      public:
  11.         Values(std::string,int,std::string,int,int);
  12.         void printValues();
  13.      };
  14.  
  15.  
  16.      Values :: Values(std::string Caddr,int Cport,std::string Saddr,int Sport,int Cid)
  17.      {
  18.         C_addr=Caddr;
  19.         C_port=Cport;
  20.         S_addr=Swaddr;
  21.         S_port=Sport;
  22.         C_ID=Cid;
  23.      }
  24.  
  25.      void Values::printValues()
  26.      {
  27.         cout << C_addr<<":" <<C_port<<":" << S_addr <<":" <<S_port << ":"<<C_ID  <<endl;
  28.      }
  29.  
  30.      map<int, Values> items;
  31.      map<Values,int> itemscopy;
  32.  
  33.      Values connection (inet_ntoa(Caddr.sin_addr),ntohs(Caddr.sin_port),inet_ntoa(Saddr.sin_addr),ntohs(Saddr.sin_port),CID);
  34.  
  35.      for(unsigned int key=0;key<=30000;    )
  36.      {
  37.         map<int,Values>::const_iterator itemsIterator=items.find(key);
  38.  
  39.         if(itemsIterator==items.end())
  40.         {
  41.            items.insert(pair<int, Values> (key, connection));
  42.            {
  43.               map<Values,int>::const_iterator itemsIterator1;
  44.               if(itemsIterator1==itemscopy.end())
  45.                  itemscopy.insert(pair<Values,int> (connection, key));
  46.            }
  47.            break;
  48.         }
  49.         else
  50.         {
  51.            cout<<"already exist";
  52.            key=key+1;
  53.         }
  54.      }
Mar 7 '14 #1
1 3925
Banfa
9,065 Recognized Expert Moderator Expert
It is doing that because the keys in a map are sorted using the < operator and your class Values has no implementation for this operation.

Add operator< to the class values.
Mar 7 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
9021
by: Ensoul Chee | last post by:
I used #include <iostream.h> int m; cout << "Hexadecimal == 0x" << hex << m << endl; to print value of m in hexadecimal mode. But I got the compile error like this couttest.cpp:20 `hex' undeclared (first use this function)
5
1836
by: Steel | last post by:
Hi at all, please consider this : <ul> <li><a>No link</a></li> <li><a href="#">This is a link</a></li> <li><a>No link</a></li> <li><a href="#">This is a link</a></li> .................... </ul> How can I do to match the <li> element that have as son the <a
2
3244
by: ABC | last post by:
How can I fixed this error? Server Error in '/MAXXWeb' Application. -------------------------------------------------------------------------------- Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
5
4499
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by including the -q64 option in xlC compiler. And we are able to link all these libraries to one of the main applications and generate an executable. SKLoader. But, when we try to run this main executable, we are getting the following errors:
1
8576
by: runistel | last post by:
i cant seem to find any fault, can anyone point out the error? void Itinerary::print() { list<Place>::iterator i; for(i = placelist.begin(); i != placelist.end(); i++) { cout << *i << endl; //error }
3
3093
by: Yash | last post by:
Hi all, I found that while we are updating our application, the application is not known to tomcat, untill it is completed. So tomcat sends 503 page as resource not found. I want to know is virtual hosting is the right way to deal with this issue. Is it possible to customise the 503 page, so that, for any resource not found issue, tomcat displays the customised page. I am trying to set the page in tomcat directory itself. I have gone...
1
10243
by: lovecreatesbea... | last post by:
In the following function `HardwareStatusDb()', If its arguments are declared as type of `string', I get: main.cpp:5: error: expected initializer before ‘int’. The error disappears when those arguments are declared as type of `string &'. Why am I getting this error?
5
5717
by: JerryBrit | last post by:
When compiling the below I get the following error: no match for 'operator<<' in 'log << std::endl' main.cpp Why can't I use std::endl in my class? #include <iostream> class Logger { public:
1
9831
by: Michael Fox | last post by:
The following code won't compile with g++, instead giving me the error: ----------------- prog2.cpp:36:33: error: declaration of ‘operator<<’ as non-function prog2.cpp:36:32: error: expected ‘;’ before ‘(’ token prog2.cpp: In function ‘int main()’: prog2.cpp:49:12: error: no match for ‘operator<<’ in ‘std::cout << z’ ------------------ My code is below, it is a simple complex number class:
0
8411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.