How to create my own header file in c++?

Yes, you can create your own header file.

  1. Kindly go through thinking in c++ by bruce eckel vol 1.
  2. Just to begin with, a header file is which has extension '.h'/'.hpp'
  3. These files have declaration of user defined data structures and interfaces such has class declaration, function prototypes and etc.
  4. After declaring and storing it into project folder. you need to include this file in .cpp/.c eg.:

file: myheader.h

#ifndef MYHEADER 
#define MYHEADER
    ......
#endif

file: myclass.cpp

#include <iostream.h>
#include "myheader.h"

Yes, of course you can, but before that you need to learn what header files are and how you can use them properly.

file: yourname.h

#ifndef YOUR_NAME_INCLUDE
#define YOUR_NAME_INCLUDE

/* Your function statement here */
#endif

yourname.cpp

#include <iostream.h>
#include "yourname.h"

/* Your function definition here */

main.cpp

#include <iostream.h>
#include "yourname.h"

/* Your function calling here */

To learn more about header files and include statements, click the link below.

Header tutorial

Tags:

C