### Parabola Class issue

Hi all, my code builds fine, but when I go to run it, it gives me multiple errors. Not sure why, and after playing around with it for the past hour, I need a second opinion as to why it's not working. It's saying their is an unidentified reference to Parabola and set precision.

The program basically is calculating parabolas and seeing the concavity using a class.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115`` ``````#include using namespace std; class Parabola{ private: double Coeff, aCoeff, bCoeff, cCoeff; double sqrt(double a); public: Parabola(double a, double b, double c){ if(a==0) Coeff = 1; else aCoeff = a; bCoeff = b; cCoeff = c; } double calcDiscrim(){ return( (bCoeff * bCoeff) - (4 * aCoeff * cCoeff) ); } double calcRoots(double &root1, double &root2){ if(calcDiscrim()==0){ root1 = -bCoeff / (2 * aCoeff); return 1; } if(calcDiscrim()>0){ root1 = (-bCoeff + sqrt(calcDiscrim())) / (2 * aCoeff); root2 = (-bCoeff + sqrt(calcDiscrim())) / (2 * aCoeff); return 2; } if(calcDiscrim()<0) return 0; } double calcX(){ return (-bCoeff / (2 * aCoeff)); } double calcY(){ return ((aCoeff * calcX()) + (bCoeff * calcX()) + cCoeff); } void printEquation(){ cout << aCoeff << "x^2 + " << bCoeff << "x + " << cCoeff << endl; } void printVertex(){ cout << "Vertex Coordinates: ("<< calcX() << "," << calcY() <<")" << endl; } void printRoots(){ double number; double root1, root2; double &a = root1; double &b = root2; int setprecision(int a); number = calcRoots(a, b); if(number==0) cout << "There are NO real roots" << endl; if(number==1) cout << "There is one real root with X-Coordinate root_1_value" << fixed << setprecision(3) << &a << endl; if(number==2) cout << "There are two real roots with X-Coordinate root_1_value" << fixed << setprecision(3) << &a << "and root_2_value" << fixed << setprecision(3) << &b << endl; } void printConcavity(){ if(aCoeff < 0) cout << "The parabola opens Downward" << endl; else cout << "The parabola opens Upward" << endl; } void print(){ printEquation(); printVertex(); printConcavity(); printRoots(); } }; int main(){ Parabola p1(1, 4, -5); Parabola p2(0, 0, 25); Parabola p3(-1, 2, -1); Parabola p4(-12, -2, 3); Parabola p5(12, 2, 3); cout << "The first parabola:" << endl; p1.print(); cout << "The second parabola:" << endl; p2.print(); cout << "The third parabola:" << endl; p3.print(); cout << "The fourth parabola:" << endl; p4.print(); cout << "The fifth parabola:" << endl; p5.print(); return 0; }``````

Thank you for any help!
You can fix most of the errors by adding the missing headers:
 ``12`` ``````#include #include ``````

Then delete lines 8 and 65:
`double sqrt(double a); // delete this line `

`int setprecision(int a); // delete this line `

That worked! Thank you very much!!!
Topic archived. No new replies allowed.