I was told by my professor that my function prototypes should be included in my *.h file. But, do I also include the function definitions in that file, or do those go in my *.cpp file? Please help..
Josh Stevanus
[email protected]
I was told by my professor that my function prototypes should be included in my *.h file. But, do I also include the function definitions in that file, or do those go in my *.cpp file? Please help..
Josh Stevanus
[email protected]
An example of how you potentially could have things set up in a sample project...
File.H
File.CppCode:#ifndef FUNC_H #define FUNC_H int func(int); #endif
Main.CppCode:#include "File.H" int func(int data) { ... }
Thus this sample project has 2 cpp files and 1 header file. You compile the 2 cpp files into object files and its the linkers job to combine those (typically along with some other library code) into a fully functioning executable file.Code:#include "File.H" int main() { int result, val; ... result = func(val); }
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens