Im trying to run a program with templates using operator < ,> methods, im getting a compiler error telling me "instantiated from here" and cannot convert Temps<double>' todouble' in return ,,The problem starts when i call the operator function Heres the code..
template <class T> class Temps { private: T a; public: Temps() { } Temps(T b) { a=b; } T operator<(Temps c) { if (a < c.a) { return *this; } return c; } T operator>(Temps c) { if (a > c.a) { return *this; } return c; } }; int main() { double d1 = -9.002515,d2=98.321,d3=1.024; Temps<double>mag(d1); Temps<double>lag(d3); Temps<double>tag; tag=mag < lag; system("pause"); return 0; }
<to find the max.<should returnbool.<operator I've ever seen.maxand aminunction for this instead of an operator which the casual reader of your code expects to do something completely different from what it does?