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
jrstevan@svsu.edu
This is a discussion on *.h file, function definitions.. help within the C++ Programming forums, part of the General Programming Boards category; I was told by my professor that my function prototypes should be included in my *.h file. But, do I ...
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
jrstevan@svsu.edu
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); }
I used to be an adventurer like you... then I took an arrow to the knee.