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. -
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;
-
}
-
}
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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)
|
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
|
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.
|
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:
|
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
}
| |
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...
|
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?
|
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:
|
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:
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |