Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.67/5 (5 votes)
See more:
Hi!
Please tell me how one can create a header or .h file in C++.
Please help me.

Thanks in advance!
Posted
Updated 22-Jun-11 6:33am
v3

Since a header file is plain text file, you may create it with a text file editor (like Visual C++ IDE's one) or, for instance, the notepad (I suggest you Notepad++).
However, in order to write meaningful content inside the header file you have to read (at least) a tutorial about C++ programming language.
:)
 
Share this answer
 
You should consider buying a good C++ book before asking basic and inane questions here. We love to help, but a question like that leaves us worried what we can say, and hope you will understand it.
 
Share this answer
 
If you are using Visual Studio

Right Click Project -> Add New Item -> Header File -> Add header file Name -> OK

and here is your new header file using MSVC


If in case you are using turbo C or GCC, use notepad

open notepad and save the file within inverted double quotes as "filename.h"

you can save it to any path as required.

Then in you cpp file, you can include this file as using include statement


Here is an example...




#include "headerfileName.h" //including the header file you created

int main() {

//code

return 0;
}

Best of Luck..! :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900