Fishery
Catch many information here
Archives
- January 2012
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- April 2009
- March 2009
- February 2009
- January 2009
-
No Comments
It is possible to create /design a header file in c++. Just declare your prototype functions in a c++ file.
For example:
#define RES_32
Void masters(){
….. your functions
}
You save this file as an “.h” extension, and include it within your program. Then you use all the functions in your c++ course file/program.
You can create header files in c/c++. The only thing you have to do is write your program without main() and store this program with extension “.h”. It is the best if you store it in the folder which contains all the header files. We can have header files like this and use them as we use other header files.
The way to write header files is:
functions.h:
int sum( int a, int b);
functions.cpp:
#include “functions.h”
int sum(int a, int b){
return a+b;
}
Compile:
g++ -c functions.cpp –o functions.o
main.cpp:
#include”functions.h”
main() {
cout<<sum(1,2)<<endl;
}
Compile and execute main:
g++ main.cpp functions.o –o main
main

