| | |
#include custom files
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2004
Posts: 489
Reputation:
Solved Threads: 5
Hello, in 'cpp' code if I wish to include a header file its .H...ie
//function definitions are located in function.h . The implementation is loaded in functions.cpp, however some of the functions take parameters created in main. Therefore rather than including the following:
that works but isnt the corect / best way is it? But when I create a link in the .h to the .cpp and vice versa it errors...any ideas?
Is the quote way the only way to fix it?
Cheers
//function definitions are located in function.h . The implementation is loaded in functions.cpp, however some of the functions take parameters created in main. Therefore rather than including the following:
•
•
•
•
#include <iostream>
...
function.h
function.cpp
...
int main()...
Is the quote way the only way to fix it?
Cheers
never never include *.cpp files inside othere *.cpp files. The *.cpp files should be compiled separately and both linked together. The header.h file should be included in both *.cpp files
now depending on the compiler you should have a project that includes both *.cpp files and links them both along with other system libraries to produce the final executable program.
C++ Syntax (Toggle Plain Text)
// header.cpp // // system includes #include <iostream> // local includes #include "header.h" // header implmentation code // // blaba
C++ Syntax (Toggle Plain Text)
// main.cpp // header.cpp // // system includes #include <iostream> // local includes #include "header.h" int main() { // blabla }
now depending on the compiler you should have a project that includes both *.cpp files and links them both along with other system libraries to produce the final executable program.
•
•
Join Date: Dec 2004
Posts: 489
Reputation:
Solved Threads: 5
ok then this aint working right...at the moment i have...
in main.cpp
the reason I've done it because its compiles... if I did this:
main.cpp
and try and compile that I get over 73 error messages since some varibles that main create are used in the functions........
in main.cpp
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; #include functions.cpp #include funct.h
the reason I've done it because its compiles... if I did this:
main.cpp
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; #include funct.h ----- funct.h #include functions.cpp -------
I thought we went through this already.
http://www.daniweb.com/techtalkforums/post106155-6.html
http://www.daniweb.com/techtalkforum...169#post106169
Is this something new and different?
http://www.daniweb.com/techtalkforums/post106155-6.html
http://www.daniweb.com/techtalkforum...169#post106169
Is this something new and different?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- Why To include Header Files in Cpp and Not in C Language (C++)
- Problems with Windows Script Encoder & #include directive (ASP)
Other Threads in the C++ Forum
- Previous Thread: connectivity in Borland C
- Next Thread: CreateThread & CreateRemoteThread
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






