Can't open a .h file in main.

In the code we have a Derivative.h and a Derivative.cpp Classes inside our code. When we try to #include "Derivative.h" in our main.cpp an error shows up Error: cannot open source file "Derivative.h".
How can i fix this?
Do you have files called Derivative.h and Derivative.cpp? Sorry if this is a stupid question but you make it sound like you have classes named Derivative.h and Derivative.cpp.
Last edited on
Yes i do have files Derivative.h and Derivative.cpp. Sorry for the confusion.
Last edited on
Check that the files are located in the same directory as your main.cpp.
Then check (and double check) the exact spelling of the names, both the actual file, and the name stated in your program source code.
What do you mean by the same directory? Because they are in the same folder as main.cpp. And open when main.cpp opens and the spelling of the names is exactally the same.
Last edited on
directory = folder
So i have the Derivative.h and Derivative.cpp in the same folder/directory and they are spelled the same but it still shows the error.
Check for the Case, prefer to use only one case for all the names in the code...
Ok i got that figured out but now can someone tell me where i am wrong with my logic?

The console asks for a char of 's' || 'c' || 't' || 'e' || 'n' || 'o' and if it is not one of these a while loop below shows up. But the while loop always implements even if it is one of those values.

while (x != 's' || 'c' || 't' || 'e' || 'n' || 'o') {
cout << "YOU BLEW IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
cout << "Enter the correct function id (s=sin, c=cos, t=tan, e=sec, n=csc, o=cot): ";
cin >> x;
if (x == 's' || 'c' || 't' || 'e' || 'n' || 'o') {
The first condition should look like this:
(x !='s' && x !='c' && x !='t' && x !='e' && x !='n' && x !='o')

and the second like this:
(x == 's' || x =='c' || x =='t' || x =='e' || x =='n' || x =='o')

Notice when you combine multiple tests using the not-equal operator !=, you need to use && rather than ||

Yes that worked thank you
Topic archived. No new replies allowed.