# No such file or directory error

I'm still learning classes in C++ and I don't understand this error that I'm getting from `#include QuadraticEquation`. Here's my code:

#include <iostream>
#include <cmath>
using namespace std;

private:
double a = 0, b = 0, c = 0;
public:
QuadraticEquation(double a, double b, double c)
{
this-> a = a;
this-> b = b;
this-> c = c;
}
double getA(){
return a;
}
double getB(){
return b;
}
double getC(){
return c;
}

double getDiscriminant(){
return (pow(b, 2) - 4 * a * c);
}

double getRoot1(){
return ((-b + sqrt(pow(b, 2) - 4 * a * c)) / (2 * a));
}
double getRoot2(){
return ((-b - sqrt(pow(b, 2) - 4 * a * c)) / (2 * a));
}
};

int main()
{
double a = 0, b = 0, c = 0;
//User enters values for a, b, and c.
cout << "Enter the values for a, b, and c: ";
cin >> a >> b >> c;

//Object created.

if (q1.getDiscriminant() > 0){
cout << "Root 1: " << q1.getRoot1() << ", Root 2: " << q1.getRoot2() << endl;
//Two Roots
}else if (q1.getDiscriminant() == 0){
//One root
cout << "Root 1: " << q1.getRoot1() << endl;
}else{
//No roots
cout << "The equation has no real roots." << endl;
}
}

+1 vote
answered Apr 20, 2023 by (88,110 points)
selected Apr 20, 2023 by Caleb Murnan

You do not have a file called QuadraticEquation. If you remove the line

`#include "QuadraticEquation"`

commented Apr 20, 2023 by (230 points)
So the only time I'll ever use `#include "QuadraticEquation"` is if I use the class in a seperate file from main?
commented Apr 20, 2023 by (88,110 points)
Something like that. :)
commented Apr 20, 2023 by (230 points)