Connecting Tech Pros Worldwide Forums | Help | Site Map

how to create a header file in c++

Newbie
 
Join Date: Oct 2006
Posts: 20
#1: Oct 22 '06
Hi all,

Can u tell me steps by step as how to create header file with my own defined functions and where to place it in TC folder. I tried to save it in INCLUDE but failed terribly.

arne's Avatar
Expert
 
Join Date: Oct 2006
Posts: 306
#2: Oct 22 '06

re: how to create a header file in c++


Quote:

Originally Posted by Shana

Hi all,

Can u tell me steps by step as how to create header file with my own defined functions and where to place it in TC folder. I tried to save it in INCLUDE but failed terribly.

Did you try to put it in the same directory as your source code file?
(What is TC, btw? Turbo-C?)
Newbie
 
Join Date: Oct 2006
Posts: 20
#3: Oct 23 '06

re: how to create a header file in c++


Yes TC for Turbo C, I have created header file called "header.h" and saved in include, and then I have created function program and had saved in LIB. After that I wrote a main program which use that function and header file and saved it in bin. Now the prob is when I compile it, I do not get any error however executing the program gives linker error that it does not recognise the function.
arne's Avatar
Expert
 
Join Date: Oct 2006
Posts: 306
#4: Oct 23 '06

re: how to create a header file in c++


Quote:

Originally Posted by Shana

Yes TC for Turbo C, I have created header file called "header.h" and saved in include, and then I have created function program and had saved in LIB. After that I wrote a main program which use that function and header file and saved it in bin. Now the prob is when I compile it, I do not get any error however executing the program gives linker error that it does not recognise the function.

I am not at all familiar with Turbo C I have to admit, but:
- there should either be the concept of a "project" to which you add your header files; the IDE will then take care of compiling and linking all the stuff; or
- you have to define an include path to tell the IDE where it can find the headers

These are the typical approaches I would say.

Did you try to store your headers in the same dir as you cpp files? This would be a starting point.
Newbie
 
Join Date: Oct 2006
Posts: 20
#5: Oct 23 '06

re: how to create a header file in c++


yes i did try it, as far as i know the project thing is in Visual C++. Right now i cannot be online but I will come back tommorow with the enitre code as it is small program just to make sure that a header file can be created and linked with Turbo C++ libraries.
Newbie
 
Join Date: Feb 2007
Posts: 1
#6: Feb 14 '07

re: how to create a header file in c++


hi! any one of u can teach me how i can make my own header file using turbo c++??????
Member
 
Join Date: Feb 2007
Posts: 52
#7: Feb 14 '07

re: how to create a header file in c++


I think ARNE is correct. You should set the path to the "include" directory.
But here's a catch : If your IDE is supporting other programs, i.e. no linker errors are coming in other programs, then I think you should study the user manuals of TurboC++ get thinks right.
Pawan
Newbie
 
Join Date: Jul 2008
Posts: 2
#8: Jul 2 '08

re: how to create a header file in c++


actually i want to step by procese how to make header file in tourbo c please sende me the procese
Newbie
 
Join Date: Jul 2008
Posts: 2
#9: Jul 2 '08

re: how to create a header file in c++


Quote:

Originally Posted by arne

Did you try to put it in the same directory as your source code file?
(What is TC, btw? Turbo-C?)

yes i want to step by step procese how to create my own library header file in torbo c editer
Familiar Sight
 
Join Date: Mar 2008
Posts: 174
#10: Jul 2 '08

re: how to create a header file in c++


In you main.cpp file or whatever you named it at the top did you put:
Expand|Select|Wrap|Line Numbers
  1. #include<header.h>
because if you didn't it wont work.
Reply