This isn't related to any problem I'm having, but I'd like to understand this issue once and for all.
When people do something like:
I often see replies saying "you can't include .cpp files. Only header files!"Code:#include "myfile.cpp"
I beg to differ. Here's a little example I prepared:
hellomain.cpp code
helloworld.cpp codeCode:#include <iostream> #include "helloworld.cpp" using namespace std; int main() { helloWorld(); cin.get(); return 0; }
Assuming both .cpp files lie in the same directory, I can compile and execute hellomain.cpp just fine! I don't even need to create a project file in Dev-C++ for this to work!Code:#include <iostream> using namespace std; void helloWorld(); void helloWorld() { cout << "Hello World!" << endl; }
So the question is... Is there something I'm missing? Why exactly do people say we can only include header files? Is it something else I should know?
Looking forward to your replies.