I want to do a for loop on values of a std::map
called ORIGIN
shown below from a lower value to the upper value:
I need to overload the <
operator in order to do it.
myclass
{
typedef std::vector<tactics*> origin_of_tactics;
typedef map<float, origin_of_tactics, CompareFloat> ::iterator iter_type;
iter_type it;
map<float, origin_of_tactics, CompareFloat> ORIGIN;
for (it = ORIGIN.find(low_value_in_bar); it <= ORIGIN.find(high_value_in_bar); it++)
{
}
} // end of myclass
I saw an example for overloading an operator and I tried to change it but I´m not sure how to use it in my class. and if its the correct way to do it:
class Complex
{
public:
typedef std::vector<tactics*> origin_of_tactics;
typedef map<float, origin_of_tactics, CompareFloat>::iterator iter_type;
bool Complex::operator <(const iter_type &other);
Complex(iter_type value) : it1(value)
{};
bool operator <(const Complex &other);
private:
iter_type it1;
};
bool Complex::operator <(const iter_type &other)
{
if ((it1->first) < (other->first))
{
return TRUE;
}
else
{
return FALSE;
}
}
How to do it? and how to write it in a general way for any type of MAP iterator < comparison? Thanks