2.9. Setting Up a Header File

Before I can invoke seq_elem(), I must first declare it to the program. If it is invoked in five program text files, there must be five declarations available. Rather than separately declare seq_elem() in each of the five files, we place the function declaration in a header file. The header file is then included in each program text file that wishes to use the function.

Using this convention, we need maintain only a single declaration of a function. If its parameter list or return type changes, only this one declaration needs to be modified. All users of the function automatically include the updated function declaration.

Header files by convention are given a .h suffix — except for the standard library header ...

Get Essential C++ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.