Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Header File in C++

Status
Not open for further replies.

benaam

Programmer
Jan 11, 2001
20
US
1300.1

Hi All
I am a novice to C++. So dont know anything about it. Now i have written a .cpp file say A.cpp and want to include it in B.cpp. Initially what I was doing was just including A.cpp in B.cpp but later I found out that it is not the right way. But i am unable to figure out how to make a header for A.cpp. My A.cpp file goes the following way:
#include <I include sone header files here>

class A {
private:
static char *ca1;
static char *ca2;

static void readFile(void);
static string wirteFile(void);

}

char* A::ca1 = new char[10];
char* A::ca2 = new char[10];

void readFile() {
cout<<&quot;hello&quot;;
}
void writeFile() {
cout<<&quot;hello&quot;;
}

Now what all shoud I include in header file and what all remain in my .cpp file???

Thanx in advance

 
Usually, function prototypes &amp; #defines are declared in the header file (*.h or *.hpp) Sometimes comments on how to use the functions are also in there.
The bulk of the functions, and the prgram entry point go in the *.c or *.cpp file. The #include FILE directive just basically pastes the contents of FILE into the location where it is declared.
Sometimes programmers will divide a complex project into several *.cpp &amp; *.hpp files just to keep things simple and help manage different parts of the development cycle separately.


Kim_Christensen@telus.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top