I need help on how to run code with (#include "Rectangle.h") in Dev-C++ IDE. Every time I try to run the code below with Dev-C++ or online GDB, I keep getting compilation termination notice (Error ) Rectangle.h: No file or directory.
I like using Dev-C++ IDE, how can have my IDE recognize this directory? Eclipse and Virtual Studio always hang my computer that is why I don't use them.
Below is the code:
// This program demonstrates memberwise assignment.
#include <iostream>
#include "Rectangle.h"
using namespace std;
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.
I found the second link to be the most help.
The short answer is when a header file is in double quotes it needs to be in the same directory as the ".cpp" file that is loading it. The other alternative is to use a path to the file if needed.
The short answer is when a header file is in double quotes it needs to be in the same directory as the ".cpp" file that is loading it.
Nonsense. The header file can be in any of the directories that is specified as part of the include path.
@Keked10 You need to find out what directory your Rectangle.h file is in, and make sure you're telling the compiler to look for include files in that directory.
#include "..." adds the directory of the current file to the search directories. The compiler searches for the header in the 'current' directory first. If the file is not found then it behaves like #include <...> which is looking into the specified directories.
That is why I called it the short answer because I could not put the time into explaining everything then and was hoping for a response from OP to see what I needed to expand on.
It is nonsense to say the Rectangle.h header file needs to be in the same directory as the OP's source. That is an outright lie.
It would have been perfectly possible to express, simply and clearly, the idea that putting the header file into the same directory would enable the compiler to find it, without saying something that is factually untrue.
Don't say things to beginners that aren't true. They might end up believing you, causing them problems down the line.
The IDE i use is Dev-C++, how do i put the Rectangle.h header file into its directory. i have checked both the save location and the app download location but i do not know how to put the header file into a directory, I need help please, remember i am still a beginner.