I do not like what I have seen in this thread so far. The case is not closed as far as I am concerned.
Dev-C++ seems to absolutely require that the deffinitions file for a header have the extension hpp instead of cpp.
What do you mean by this? I don't like the terminology used. A header file is used for declarations, so are you referring to the header file or the source file that is the companion to the header file? (A source file would contain definitions). Either way, a .h / .cpp scheme works just fine. Dev-C++ is an IDE for MinGW, which in turn is the windows port of gcc. Believe me when I say that it's very, very, very unlikely gcc requires .hpp, as heh, tell that to the entire linux world. And me.
I'd like to see the the compiler version. Open up command prompt, go to the directory where Dev-C++ installed all the MinGW executables. Type in g++ -V and post the output here.
There also seems to be confusion on the part of what the relationship between include directives, .cpp, and .h files are. And Ganon, I'm very curious as to what compiler you have that requires single files for source code.
Question for you people. Why do we have header files, and why do we include them? Well, including them is the rough act of copy and pasting, so here's the big question. Why does the material in header files get copy and pasted at the beginning of source files? What's the reason we need to do so?
Take an example:
-
//Also declared in someFunc.h as int someFunc();
-
int someFunc()
-
{
-
....
-
}
-
-
//main.cpp
-
int someFunc(); //from an include someFunc.h
-
-
int main()
-
{
-
...
-
someFunc();
-
...
-
}
-
Why do we have a forward declaration in main.cpp? After all, we have the function defined in somefunc.cpp. It's because
the compiler deals with source files independently. It will never know about the existence of other source files, even if you tell it to compile multiple files at once. Yet, to compile, you must have valid syntax, which requires knowledge of what you have created in other source files. So the solution are declarations, which do not seek to define what the functions and classes and variables in other source files. Just their existence, so the compiler can compile a source file properly.
It is only in the linking stage, that everything gets put together. You leave this up to the linker. It will take all the compiled translation units and create the appropriate binary file from them.