Re: Multimap insert issue
Somehow, you need to define an operator that supports a comparison. Maps are implemented internally with a tree structure. Internally, there are certain things that map needs to be able to do with each entry.
1) The key/value pair must be assignable and copyable (the struct is both since it is POD).
2) The key must be comparable with the sorting criterion (Your struct is not comparable since it has no operator< defined).
The key must have operator< defined by default, unless you specify a third template argument when instantiating your multimap (and then you need to define whatever is needed to support the specified comparison). This operator is not defined, by default for a struct type. Only the assignment operator and copy constructor are. You have to define operator< yourself. Sorry, i don't have time to post an example, but that's the basic issue. You can do a google search and find some examples.
Good luck.
Re: Multimap insert issue
Code:
struct si{
int x0;
int ch;
friend bool operator< (const si& a, const si& b);
};
bool operator< (const si& a, const si&b)
{
if (a.x0 < b.x0) return true;
else return false;
}
The rest remains intact.
Thanks a bunch mate! I did it, with your help. I overloaded operator< for my si struct and then it worked perfectly.