I have two containers with the type of A
A<string, double> s1;
A<string, bool> s2;
So I wrote the A class with the necessary functions and I used a
template<class T, class E>
for it. It has a function that returns a value of E, in my case, it returns a double which I'm trying to compare to another double. I'm supposed to overload the < operator for that, but I have no idea how to do that.
4.5 < s1.at("a");
s1.at("a"); returns 1.5, so it's false. I need it to return true.
I thought since they are both double values, I can just
bool operator< (double& rhs) {
return rhs < *this;
}
But it's not working. I also thought it should be friend with two parameters, but it just doesn't make sense since the rhs is a double returned by a function, not a type of A.
So I guess it really is two different types and that's why my first idea is not working.