473,382 Members | 1,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

what is .h file's function?

I don't know why c++ divide source file into .cpp file and .h file.

who can tell me?
thanks

May 9 '06 #1
4 1503
<co*****@gmail.com> wrote:
I don't know why c++ divide source file into .cpp file and .h file.

who can tell me?


In small programs it is mainly used to provide function prototypes that may
be used by the following program.

In large programs it provides a central repository that allow a number of
..cpp files (I will call them modules here) to communicate with each other.
If you have one header file, say mwp.h, (my wonderful program) you can put
all the (home-brew) function prototypes, struct and class definitions and
other neat stuff. All the .cpp files would have an #include "mwp.h" and
it is the fundamental means of inter-module communications.

Some of the other neat stuff can include macros, enums, typedefs, forward
declarations, constants, external declarations for primitive variables used
by more than one module and perhaps more. Slovenly types can put global
variables in an .h file.
May 10 '06 #2
osmium wrote:
<co*****@gmail.com> wrote:
I don't know why c++ divide source file into .cpp file and .h file.

who can tell me?


In small programs it is mainly used to provide function prototypes that may
be used by the following program.


what is prototypes? how can it be used by the following program?

declaration?


thanks.

May 10 '06 #3
co*****@gmail.com wrote:
I don't know why c++ divide source file into .cpp file and .h file.

who can tell me?


About 200 good books, wikipedia, google, jeeves, ...

(Ever heard of doing a bit of research and keeping yourself in people's
good books until you get a _really_ tough one you need help for?)

--
Ron House ho***@usq.edu.au
http://www.sci.usq.edu.au/staff/house
May 10 '06 #4
conglay wrote:
what is prototypes? how can it be used by the following program?

declaration?


What does your C++ tutorial say about these things?

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
May 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Xah Lee | last post by:
in computer languages, often a function definition looks like this: subroutine f (x1, x2, ...) { variables ... do this or that } in advanced languages such as LISP family, it is not uncommon...
31
by: Steven T. Hatton | last post by:
If a header is not necessarily a source file, and the sequences delimited by < and > in header names aren't necessarily valid source file names, what exactly is a header? -- p->m == (*p).m == p.m...
5
by: Dennis | last post by:
if you have the headers and main in below code snippet, the below ios::noreplace creates an error: error C2039: 'noreplace' : is not a member of 'basic_ios<char,struct std::char_traits<char> >'...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
9
by: Curious Student | last post by:
Some places till now, I've seen function prototypes within functions instead of in the global declaration space, which I thought was the way. I thought it was <I>only</I>: int myfunction(int,...
21
by: tyler_durden | last post by:
hi there peeps... like I say in the topic, I need to do an e-mail program in C language, and has to be made until the 3th of january..the problem is I'm having some problems with it. I was...
2
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
2
by: teddybyte | last post by:
my script below is: #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, ...
9
by: xiao | last post by:
It always dumped when I tried to run it... But it compiles OK. What I want to do is to do a test: Read information from a .dat file and then write it to another file. The original DAT file is...
4
by: hirsh.dan | last post by:
i have a functions that writes information to a file. inside that function i have a line in which i call another function. if this line is executed, nothing is written to the file, but if i remark...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.