/* * Polynomial simple tester (again). This is exactly like the * first one, except we pass the polynomial object by pointer. */ #include #include using namespace std; #include "poly.h" void polyrunner(string label, const Polynomial *p) { cout << "f(x) = " << p->tos() << endl; cout << "f'(x) = " << p->dx().tos() << endl; for(double d: { 3.1, 0.0, -5.2, 8.33, 1.0, 7.15, -1.0, 2.13, -4.2 } ) { cout << "f(" << d << ") = " << p->f(d) << endl; } cout << endl; } int main() { Polynomial p1(13.1); polyrunner("p1", &p1); Polynomial p2(-2.8, 1.0, 3.3); polyrunner("p2", &p2); Polynomial p3 = { 3, 8.1, 0.0, -4.1 }; polyrunner("p3", &p3); Polynomial p4 = { 7.8, 0.0, 0.0, -2.31, 0.0, 0.0, 7.0, 0.0 }; polyrunner("p4", &p4); }