-
#include
I have three files.
main.cpp
webcounter.cpp
webcounter.h
I have my class declarations in my webcounter.h file.
I have my class definitions in my webcounter.cpp file.
How do I include both files to run in my main.cpp file?
My professor told us we shouldn't include .cpp files, yet I'm not understanding another way to get both my class definitions and declarations to be understood in the main.cpp file so they can compile correctly.
If i include the .cpp file into my main.cpp file, it works, but I want to know the correct way of going about this.
Thank you :)
-
How are you compiling your program? What compiler/IDE? You should be adding the .cpp file to your project, not including the file.
Jim
-
I'm not sure I understand. I created the file in vim, and I compiled it in the command prompt using g++ main.cpp
I have a feeling you're asking a more in depth question than I can answer, I'm new to programming.
-
How would I go about adding a .cpp file to my project? With a makefile?
-
> I'm not sure I understand. I created the file in vim, and I compiled it in the command prompt using g++ main.cpp
In which case, the simple answer is
g++ main.cpp webcounter.cpp
When you get a few more files, this gets cumbersome, at which point you'll be eager to know about makefiles.