O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C++ Header Files

C++ header files store the following:

  • Class definitions

  • Class-independent data structures

  • Application-specific constants

  • Class-specific constants

In other words, anything that is not code goes into a header file. This means that you’ll probably need to protect the files against multiple inclusion, as detailed in Chapter 14.

This example assigns the header files the standard .h extension, much as you would a normal C header file. Some implementations will use .hpp to associate the filename with C++ rather than C, but this is not necessary.

Try to keep OO code and application startup code as separate as possible, and limit each header file to prototyping a single class.

It is worth noting, because you’ll likely come across an example ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required