Including Header Files in C++
Hi, I'm using Dev C++ for my programming projects right now. So far, I haven't been able to include header files in my program.
For example:
I make a cpp file called main_O
I use #include "main_O.cpp" to try to include the file into my project. It doesn't work. #include "main_O.h" or #include "main_O.hpp" don't work either. Anybody know how I include header files into my projects? Any help is greatly appreciated!
What, specifically, doesn't work?
My guess would be, you're getting an error that says something like,
Compiling...xxx.cpp(3): Could not include file "main_O.cpp": file does not exist or path is incorrect
If so, make sure your file is actually named "main_O.cpp". If your file doesn't have a cpp extension, it's just named "main_O", you just want to write #include "main_O".
Is that the problem?
My guess would be, you're getting an error that says something like,
Compiling...xxx.cpp(3): Could not include file "main_O.cpp": file does not exist or path is incorrect
If so, make sure your file is actually named "main_O.cpp". If your file doesn't have a cpp extension, it's just named "main_O", you just want to write #include "main_O".
Is that the problem?
Quote:Original post by Futurulus
What, specifically, doesn't work?
My guess would be, you're getting an error that says something like,
Compiling...xxx.cpp(3): Could not include file "main_O.cpp": file does not exist or path is incorrect
If so, make sure your file is actually named "main_O.cpp". If your file doesn't have a cpp extension, it's just named "main_O", you just want to write #include "main_O".
Is that the problem?
Nope it still doesn't work sorry.
You include headerfiles(h, hpp, hxx or whatever you use for it) not source files (c, c++, cpp, cc, cxx, ...)
Quote:Original post by 3Dgonewild
Have you added the header(and the source) in the project(Project->add to project) ?
Thats almost guaranteed to be your problem. Do as suggested, I'll bet you'll find that all works smoothly. Well, unless your code is...
I'm just teasing. ;)
FlyingIsFun1217
.cpp files are not headers.
OP really needs to read the article linked above.
OP also really needs to elaborate on what "It doesn't work." means.
Quote:Original post by Sneftel
Clicky
OP really needs to read the article linked above.
OP also really needs to elaborate on what "It doesn't work." means.
Quote:Original post by megamoscha
You include headerfiles(h, hpp, hxx or whatever you use for it) not source files (c, c++, cpp, cc, cxx, ...)
In dev c++ ,if you don't include the source files you're getting a bunch of errors.....
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement