I have the following templatе:
template <typename T1, typename T2>
class equationSolution {
public:
T1 a, b, c;
float d;
friend ostream& operator << <T1, T2> (ostream& str, const equationSolution<T1, T2>& ov);
equationSolution<T1,T2>& operator += (const equationSolution<T1, T2>& ov,const int& value);
equationSolution() : a(0), b(0), c(0) {}
equationSolution(T1 a1, T1 b1, T1 c1) : a(a1), b(b1), c(c1) {
a = a;
b = b;
c = c;
d = pow(b, 2) - 4 * a * c;
}
}
I managed to overload the output
template <typename T1, typename T2>
ostream& operator << (ostream& str, const equationSolution<T1, T2>& ov)
{
str << "(" << ov.a << "," << ov.b <<","<< ov.c <<")";
return str;
}
But with the operator + = I have difficulties. That's what I did:
friend equationSolution<T1, T2>& operator += (const equationSolution<T1, T2>& ov, const int& value) {
ov.a += value;
ov.b += value;
ov.c += value;
return ov;
}
But i have eror: binary "operator + =" has too many parameters
how i can fix it?
Aucun commentaire:
Enregistrer un commentaire