Почему я не могу умножить полином на число?
[Error] no match for 'operator<<' (operand types are 'std::basic_ostream' and 'Polynom')
Вызов:
cout << "5 * g = " << g * 5 << endl;
В класе:
Polynom Polynom::operator *(double c) {
return multiple(c, *this);
}
Polynom multiple(double c, const Polynom& p) {
if (c == 0) {
Polynom result;
return result;
} else {
int degree = p.degree;
double* new_exponents = new double[degree];
for (int i = 0; i < degree; i++) {
new_exponents[i] = c * p.exponents[i];
}
Polynom result(degree, new_exponents);
delete[] new_exponents;
return result;
}
}
ostream& operator <<(ostream& os, Polynom& p) {
os << "{ degree: " << p.degree << "; coefficients: " << p.getCoefficientsStr() << " }";
return os;
}