![]() |
|
[C] How to create HEADER FILE in c++...and can we include our own methods init - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C] How to create HEADER FILE in c++...and can we include our own methods init (/showthread.php?tid=1270972) |
How to create HEADER FILE in c++...and can we include our own methods init - dilipkumarthota - May 5, 2011 hi frndz, how to create HEADER FILES in c++...if so i wanna put some classes and functions to it..can we do this..😅 * - bsod666 - May 5, 2011 A header file is just a C++ source file, like a cpp file, except it has the h (or hpp) extension. The main difference though is that it doesn't get compiled by the compiler, instead it gets placed inside your cpp file that includes it before the cpp gets compiled (part of the preprocessor step). So say I have two files (test.cpp and test.h) like this: test.h: Code void myfunc(int param);test.cpp Code #include "test.h"Now the first thing the compiler does to build test.cpp is run it through the preprocessor, after that step it will look like this: test.cpp after preprocessing: Code void myfunc(int param);Now it will be actually compiled. See how that works? Of course if this was to actually compile I'd need another source file with the actual bodies of the functions declared in test.h though, but test.h contains their declarations so other files know how to call them. * - dilipkumarthota - May 6, 2011 (May 5, 2011 05:05 PM)bsod666 Wrote: A header file is just a C++ source file, like a cpp file, except it has the h (or hpp) extension. The main difference though is that it doesn't get compiled by the compiler, instead it gets placed inside your cpp file that includes it before the cpp gets compiled (part of the preprocessor step). So say I have two files (test.cpp and test.h) like this: thanks for the code....really very helpful |