Code Yarns β€πŸ‘¨β€πŸ’»
Tech Blog ❖ Personal Blog

C++:

πŸ“… 2010-Oct-22 ⬩ ✍️ Ashwin Nanjappa ⬩ πŸ“š Archive

C++ header files should introduce as few definitions as possible. This is why it is advisable to use forward declarations of the types needed in a header file. This leads to less coupling and faster compilation times.

To help with this, the C++ standard provides the header file for use in header files. This header file contains the forward declarations of the definitions from other input-output header files like . should only be used in header files, since it is not really useful to include it in a source file (.cpp) that needs the definitions.

The definitions whose forward declarations that provides can be seen here. I find it easier to know whatΒ  are the standard header files whose definitions provides for. These are:

<cstdio>
<cstdlib>
<cwchar>
<fstream>
<iomanip>
<ios>
<iostream>
<istream>
<ostream>
<sstream>
<streambuf>