Seperate compilation in C++
Posted
by
Pat Murray
on Stack Overflow
See other posts from Stack Overflow
or by Pat Murray
Published on 2012-04-09T03:42:06Z
Indexed on
2012/04/09
5:28 UTC
Read the original article
Hit count: 219
c++
|compilation
Suppose you are creating a class with multiple .cpp files (which each contain the implementation of a member function) and have the class' declaration in a .h file. Also, each .cpp file includes the .h file via the include directive.
I was told that if you change the implementation of any of the member functions (.cpp files) that you will have to recompile every .cpp file in order to run the program. That is, if I had 5 member functions (each implemented in a .cpp file) and I changed the implementation of 1 of the .cpp files I would have to compile the 1 .cpp file I changed AND the 4 other .cpp files I didn't change in order to correctly run my program. My question, if the previous statement is true, is why is the statement is true? Any insight on this concept would be helpful.
© Stack Overflow or respective owner