Exemplo n.º 1
0
bool Polynomial::operator ==(const Polynomial &z) const {
    if (degree != z.get_degree()) {
        return false;
    }

    for (int i = 0; i < degree + 1; i++) {
        if (coefficients[i] != z.get_coefficients()[i]) {
            return false;
        }
    }

    return true;
}
Exemplo n.º 2
0
Polynomial Polynomial::operator =(const Polynomial &p) {
    if (this != &p) {
        degree = p.get_degree();

        delete[] coefficients;
        coefficients = new ComplexNumber[degree + 1];
        for (int i = 0; i < p.get_degree() + 1; i++) {
            coefficients[i] = p.get_coefficients()[i];
        }
    }

    return *this;
}