When you use a type as a key in a std::map
, the map requires operator<
to sort the elements it contains. You need to add:
friend inline bool operator<( const Person& lhs, const Person& rhs )
{
return lhs.code < rhs.code;
}
(or something other appropriate) to your class. It could also be a free function after the class if you use the getters for code
, there are several options.