Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Header file

 

Header files contain the declarations of functions and classes.

 

Header files commonly have the .h and .hpp filename extensions.

 

To use a header file, it must be #included in the source code.

 

#include <iostream>
#include "Widget.h"
 
int main()
{
  Widget w;
  std::cout << "Hello world" << std::endl;
}

 

A complete collection of header files is called a library. The C++ standard library is called the STL.

 

The combination of a header (.h) file and an implementation (.cpp) file is called a unit.

 

Make header files self-sufficient [1].

 

Always write interal #include guards [2]. Never write external #include guards [2].

 

 

 

 

 

Standard header files

 

The STL consists out of the following header files [3][4]:

 

  1. C++98C++0x algorithm
  2.  C++0x array
  3.  C++0x atomic
  4. C++98C++0x bitset
  5.  C++0x cassert
  6.  C++0x ccomplex
  7.  C++0x cctype
  8.  C++0x cerrno
  9.  C++0x cfenv
  10.  C++0x cfloat
  11.  C++0x chrono
  12.  C++0x cinttypes
  13.  C++0x ciso646
  14.  C++0x climits
  15.  C++0x clocale
  16.  C++0x cmath
  17.  C++0x codecvt
  18.  C++0x complex
  19.  C++0x condition_variable
  20.  C++0x csetjmp
  21.  C++0x csignal
  22.  C++0x cstdalign
  23.  C++0x cstdarg
  24.  C++0x cstdbool
  25.  C++0x cstddef
  26.  C++0x cstdint
  27.  C++0x cstdio
  28.  C++0x cstlib
  29.  C++0x cstring
  30.  C++0x ctime
  31. C++98C++0x complex
  32.  C++0x ctgmath
  33.  C++0x ctime
  34.  C++0x cuchar
  35.  C++0x cwchar
  36.  C++0x cwctype
  37. C++98C++0x deque
  38. C++98C++0x exception
  39.  C++0x forward_list
  40. C++98C++0x fstream
  41. C++98C++0x functional
  42.  C++0x future
  43.  C++0x initializer_list
  44. C++98C++0x iomanip
  45. C++98C++0x ios
  46. C++98C++0x iosfwd
  47. C++98C++0x iostream
  48. C++98C++0x istream
  49. C++98C++0x iterator
  50. C++98C++0x limits
  51. C++98C++0x list
  52. C++98C++0x locale
  53. C++98C++0x map
  54. C++98C++0x memory
  55.  C++0x mutex
  56. C++98C++0x new
  57. C++98C++0x numeric
  58. C++98C++0x ostream
  59. C++98C++0x queue
  60.  C++0x random
  61.  C++0x ratio
  62.  C++0x regex
  63. C++98C++0x set
  64. C++98C++0x sstream
  65. C++98C++0x stack
  66. C++98C++0x stdexcept
  67. C++98C++0x streambuf
  68. C++98C++0x string
  69. C++98C++0x strstream
  70.  C++0x system_error
  71.  C++0x thread
  72.  C++0x tuple
  73.  C++0x typeindex
  74. C++98C++0x typeinfo
  75.  C++0x type_traits
  76. C++98C++0x utility
  77. C++98C++0x valarray
  78. C++98C++0x vector
  79.  C++0x unordered_map
  80.  C++0x unordered_set

 

 

 

 

 

References

 

  1. Herb Sutter, Andrei Alexandrescu. C++ coding standards: 101 rules, guidelines, and best practices. 2005. ISBN: 0-32-111358-6. Item 23: 'Make header files self-sufficient'.
  2. Herb Sutter, Andrei Alexandrescu. C++ coding standards: 101 rules, guidelines, and best practices. 2005. ISBN: 0-32-111358-6. Item 24: 'Always write interal #include guards. Never write external #include guards'.
  3. International C++ Standard, table 11
  4. Draft of C++0x Standard, table 14 and 15, ISO/IEC JTC1 SC22 WG21 N 3290, Date: 2011-04-11, ISO/IEC FDIS 14882, ISO/IEC JTC1 SC22

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict