Chapter 6

Splitting Up Source Code Files

In This Chapter

arrow Creating multiple source code files

arrow Creating header files

arrow Sharing variables among source files

arrow Making use of the mysterious header wrappers

Just as you can divide your work into functions, you can also divide your work into multiple source code files. The main reason to do so is, simply, to help keep your project manageable. Also, with multiple source code files, you can have several people working on a single project, each working on a different source code file at the same time. The goal, of course, is to make sure that your coworkers work on the harder parts that are more grueling and no fun while you get all the credit.

The key to multiple source files is knowing where to break the source code into pieces. Like anything else, if you break the source code in the wrong place, it will, well, break.

In this chapter, we show you how to divide your source code into multiple files (and in all the right places). The examples we give use Code::Blocks; however, we also provide a few Makefile tips if you’re using other tools. (

Get C++ All-in-One For Dummies, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.