Compilation of a header file in c++

  • #1

Main Question or Discussion Point

Hi..am just learning c++...i have a doubt..

Suppose you have a header file and you include it in your main program by using the #include directive..then do you have to compile the header file separately? Or does it get compiled with the main program?
 

Answers and Replies

  • #2
mgb_phys
Science Advisor
Homework Helper
7,774
12
Or does it get compiled with the main program?
Yes, all the #include does is copy the text of the header file into the .cpp file before passing it to the compiler
 
  • #3
I guess your yes means that one does not have to compile a header file separately...and it gets compiled with the main program..?
 
  • #4
I understand..thank you..
 

Related Threads for: Compilation of a header file in c++

Replies
27
Views
2K
  • Last Post
Replies
2
Views
6K
  • Last Post
Replies
13
Views
60K
Replies
7
Views
10K
  • Last Post
Replies
20
Views
10K
Replies
7
Views
374
  • Last Post
Replies
14
Views
3K
  • Last Post
Replies
2
Views
2K
Top