Why does C++ have header files and .cpp files?

C++Server Side ProgrammingProgramming

C++ has header and .ccp files for separating the interface from the implementation. The header files declare "what" a class (or whatever is being implemented) will do, ie the API of the class, kind of like an interface in Java. The cpp file on the other hand defines "how" it will perform those features, ie, the implementation of these declared functionality.

This reduces dependencies. The code that uses the header doesn't need to know all the details of the implementation and any other classes/headers needed only for that. It just needs to focus on things it is trying to implement. This reduces compile times and the amount of recompilation needed when you change the implementation.


raja
Published on 28-Feb-2018 15:38:44
Advertisements