O'Reilly logo

C++ All-in-One For Dummies, 3rd Edition by John Paul Mueller, Jeff Cogswell

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

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. (

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