The header file is named something.h (of course, "something" is a
meaningful name). The contents could be function declarations,
structure definitions, variables, etc.
Just create the file and put the good in it.
Then you'll reference it in your program as
#include "something.h"
Its simple, just try this example, and then on you can get it right:
// myheader.h
// once you write this file save it as myheader.h
#include <iostream.h>
#include <conio.h>
void display()
{
cout<<"Hi this is from header";
}
void hold()
{
getch();
}
/************** header ends here*************************/
// myprogram.cpp
// save this file as myprogram.cpp
#include "myheader.h"
void main()
{
display();
hold();
}
Just create the file and put the good in it.
Then you'll reference it in your program as
#include "something.h"
Its simple, just try this example, and then on you can get it right:
// myheader.h
// once you write this file save it as myheader.h
#include <iostream.h>
#include <conio.h>
void display()
{
cout<<"Hi this is from header";
}
void hold()
{
getch();
}
/************** header ends here*************************/
// myprogram.cpp
// save this file as myprogram.cpp
#include "myheader.h"
void main()
{
display();
hold();
}
No comments:
Post a Comment